Skip to content

Commit

Permalink
Merge pull request #3 from MaxTCodes/main
Browse files Browse the repository at this point in the history
Adding Windows Support
  • Loading branch information
jeremytenjo authored Jan 30, 2025
2 parents f243ba7 + f8be263 commit 39e584e
Show file tree
Hide file tree
Showing 53 changed files with 534 additions and 212 deletions.
26 changes: 0 additions & 26 deletions .eslintrc.json

This file was deleted.

31 changes: 31 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: "Test Extension"
on: [push, pull_request]

jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Node.js
uses: actions/setup-node@v2
with:
node-version: '18.17.1'
- run: npm install
- name: Install APT libraries
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y build-essential xvfb clang libdbus-1-dev libgtk-3-dev \
libnotify-dev libasound2-dev libcap-dev \
libcups2-dev libxtst-dev \
libxss1 libnss3-dev gcc-multilib g++-multilib curl \
gperf bison python3-dbusmock openjdk-8-jre
- run: xvfb-run -a npm test
if: runner.os == 'Linux'
- run: npm test
if: runner.os != 'Linux'

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules
package-lock.json
.vscode-test
out
out
dist
12 changes: 12 additions & 0 deletions .vscode-test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {defineConfig} from "@vscode/test-cli";

export default defineConfig({
label: "Unit Tests",
files: 'out/src/test/**/*.test.js',
workspaceFolder: "./example/app",
mocha: {
ui: 'tdd',
timeout: 10000
},
launchArgs: ["--disable-extensions"]
})
2 changes: 1 addition & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the extensions.json format
"recommendations": ["dbaeumer.vscode-eslint"]
"recommendations": ["dbaeumer.vscode-eslint", "ms-vscode.extension-test-runner"]
}
18 changes: 14 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,28 @@
"type": "extensionHost",
"request": "launch",
"args": [
"--disable-extensions",
"--extensionDevelopmentPath=${workspaceFolder}",
"${workspaceFolder}/test/app"
]
"${workspaceFolder}/example/app"
],
"outFiles": ["${workspaceFolder}/out/**/*.js", "!**/node_modules/**"],
"cwd": "${workspaceFolder}/example/app",
"preLaunchTask": "tasks: dev"
},
{
"name": "Extension Tests",
"type": "extensionHost",
"request": "launch",
"args": [
"--disable-extensions",
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/test/suite/index"
]
"--extensionTestsPath=${workspaceFolder}/out/src/test/suite/index",
"${workspaceFolder}/example/app"
],
"testConfiguration": "${workspaceFolder}/.vscode-test.mjs",
"outFiles": ["${workspaceFolder}/out/test/**/*.js"],
"cwd": "${workspaceFolder}/example/app",
"preLaunchTask": "npm: watch-tests"
}
]
}
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"files.exclude": {
"out": false, // set this to true to hide the "out" folder with the compiled JS files
"dist": false // set this to true to hide the "dist" folder with the compiled JS files
},
"search.exclude": {
"**/node_modules": true, // set this to false to include "node_modules" folder in search results
"out": true, // set this to false to include the "out" folder in search results
"dist": true // set this to false to include the "dist" folder in search results
}
}
62 changes: 62 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "build",
"problemMatcher": "$tsc",
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"type": "npm",
"script": "dev",
"problemMatcher": "$tsc",
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": false
}
},
{
"label": "tasks: dev",
"dependsOn": ["npm: dev"],
"problemMatcher": []
},
{
"type": "npm",
"script": "build:watch",
"problemMatcher": "$tsc-watch",
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": false
}
},
{
"type": "npm",
"script": "watch-tests",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never",
"group": "watchers"
},
"group": "build"
},
{
"label": "tasks: watch-tests",
"dependsOn": ["npm: build:watch", "npm: watch-tests"],
"problemMatcher": []
}
]
}
15 changes: 14 additions & 1 deletion .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,17 @@ test/**
.gitignore
.yarnrc
assets/videos
!node_modules/esbuild
!node_modules/esbuild
**/*.js.map
scripts/**
out/**
.vscode-test.mjs
**/*.ts
**/tsconfig.*
**/eslint.config.*
example/**
src/**
utils/**
.gitattributes
jsconfig.json
.prettier*
49 changes: 49 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* ESLint configuration for the project.
*
* See https://eslint.style and https://typescript-eslint.io for additional linting options.
*/
// @ts-check
import js from '@eslint/js';
import tseslint from 'typescript-eslint';

export default tseslint.config(
{
ignores: [
"out",
"dist",
"scripts"
]
},
js.configs.recommended,
...tseslint.configs.recommended,
);



// {
// "env": {
// "browser": false,
// "commonjs": true,
// "es6": true,
// "node": true,
// "mocha": true
// },
// "parserOptions": {
// "ecmaVersion": "latest",
// "ecmaFeatures": {
// "jsx": true
// },
// "sourceType": "module"
// },
// "ignorePatterns": ["lib", "app", "out"],
// "rules": {
// "no-const-assign": "warn",
// "no-this-before-super": "warn",
// "no-undef": "error",
// "no-unreachable": "warn",
// "no-unused-vars": "error",
// "constructor-super": "warn",
// "valid-typeof": "warn"
// }
// }
9 changes: 9 additions & 0 deletions example/app/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
printWidth: 90,
trailingComma: 'all',
tabWidth: 2,
semi: false,
singleQuote: true,
jsxSingleQuote: true,
arrowParens: 'always',
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions example/app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "app",
"version": "1.0.0",
"description": "",
"main": ".prettierrc.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"@jeremytenjo/super-code-generator": "^3.31.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ import type {
const reactComponent: SuperCodeGeneratorTemplateSchema = {
type: 'React Component',
hooks: {
onCreate: async ({ outputPath }) => {
console.log(outputPath)
cp.exec(`cd ${outputPath} && touch file_name.txt`)
onCreate: async ({ outputPath, componentName }) => {
// do things here
},
},
files: [
Expand All @@ -25,7 +24,7 @@ const reactComponent: SuperCodeGeneratorTemplateSchema = {
export default function ${changeCase.pascalCase(name)}() {
return (
<div className={${wrapInTemplateLiteral('styles.wrapper')}}>
<div className={${wrapInTemplateLiteral({text: 'styles.wrapper'})}}>
${name}
</div>
);
Expand All @@ -40,9 +39,8 @@ const reactComponent: SuperCodeGeneratorTemplateSchema = {
}

// Cloud function example
const functionsFolderPath = path.join(process.cwd(), 'functions')
const cloudFunction = {
path: ({ name }) => path.join(functionsFolderPath, 'src', name, `${name}.ts`),
path: ({ name }) => path.join('functions', 'src', name, `${name}.ts`),
template: ({ name, helpers }) => `
export default function ${helpers.changeCase.pascalCase(name)}() {
return 'hello'
Expand All @@ -53,20 +51,21 @@ const cloudFunctionTemplate: SuperCodeGeneratorTemplateSchema = {
type: 'Cloud Function',
files: [cloudFunction],
hooks: {
onCreate: () => {
const functionsFile = path.join(functionsFolderPath, 'src', 'functions.ts')
fs.appendFileSync(functionsFile, 'data to append')
onCreate: ({outputPath, componentName}) => {
const functionsFile = path.join(outputPath, 'functions', 'src', 'functions.ts')
fs.appendFileSync(functionsFile, `export * as ${componentName} from "./${componentName}/${componentName}.js"\n`)
},
},
options: {
createNamedFolder: false,
outputInRootFolder: true,
},
}

// Story example
const story: SuperCodeGeneratorTemplateSchema = {
type: 'Story',
outputWithoutParentDir: true,
outputWithoutParentDir: false,
files: [
{
path: ({ name, helpers: { changeCase } }) =>
Expand All @@ -77,7 +76,7 @@ const story: SuperCodeGeneratorTemplateSchema = {
export default function ${changeCase.pascalCase(name)}() {
return (
<div className={${wrapInTemplateLiteral('styles.wrapper')}}>
<div className={${wrapInTemplateLiteral({text: 'styles.wrapper'})}}>
${name}
</div>
);
Expand Down
Loading

0 comments on commit 39e584e

Please sign in to comment.