Skip to content

Commit e02411f

Browse files
committed
✨ gecli create gei; fixed all issues
1 parent 6cd8f24 commit e02411f

26 files changed

+436
-216
lines changed

packages/cli/src/commands/common/dev.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ import { stuccoRun } from '@/common/stucco/index.js';
33
import { typescriptServer } from '@/common/typescriptServer.js';
44
import { DEPLOY_FILE, STUCCO_FILE } from '@/gshared/constants/index.js';
55
import path from 'path';
6+
import fs from 'fs';
7+
import process from 'node:process';
8+
9+
let killing = false;
10+
let changingFile = false;
611

712
export const CommandDev = async () => {
813
const { onCloseStucco, onCreateStucco } = await stuccoRun({
@@ -15,11 +20,27 @@ export const CommandDev = async () => {
1520
await onCreateStucco();
1621
},
1722
});
23+
const fileServer = fs.watch(process.cwd(), (e, f) => {
24+
if (changingFile) return;
25+
if (f === STUCCO_FILE || f.startsWith('.env')) {
26+
changingFile = true;
27+
onCreateStucco().then((e) => {
28+
changingFile = false;
29+
});
30+
}
31+
});
1832
const close = () => {
33+
if (killing) return;
34+
killing = true;
35+
logger('Exiting gracefully...', 'loading');
36+
fileServer.close();
37+
logger('FileServer closed', 'loading');
1938
tsServer.close();
39+
logger('TsServer closed', 'loading');
2040
onCloseStucco();
41+
logger('Gecli server closed', 'info');
2142
};
22-
process.on('SIGTERM', () => {
43+
process.on('', () => {
2344
close();
2445
});
2546
process.on('SIGINT', () => {
Lines changed: 42 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Auth } from '@/Auth/index.js';
2+
import { CommandBootstrapIntegration } from '@/commands/create/integration.js';
23
import { CommandBootstrap } from '@/commands/create/project.js';
34
import { projectOptions, confOptions } from '@/common/promptOptions.js';
45
import { Config, ConfigurationOptions } from '@/Configuration/index.js';
@@ -8,25 +9,46 @@ export default {
89
command: 'create <command>',
910
describe: 'Create commands. Create backend projects.',
1011
builder: (yargs) => {
11-
return yargs.command(
12-
'backend',
13-
'Create a backend project',
14-
async (yargs) => {
15-
yargs.options(
16-
confOptions({
17-
...projectOptions,
18-
}),
19-
);
20-
},
21-
async (argv) => {
22-
await Auth.login().then(Config.setTokenOptions);
23-
await CommandBootstrap(
24-
argv as Pick<
25-
ConfigurationOptions,
26-
'project' | 'namespace' | 'projectVersion'
27-
>,
28-
);
29-
},
30-
);
12+
return yargs
13+
.command(
14+
'backend',
15+
'Create a backend project',
16+
async (yargs) => {
17+
yargs.options(
18+
confOptions({
19+
...projectOptions,
20+
}),
21+
);
22+
},
23+
async (argv) => {
24+
await Auth.login().then(Config.setTokenOptions);
25+
await CommandBootstrap(
26+
argv as Pick<
27+
ConfigurationOptions,
28+
'project' | 'namespace' | 'projectVersion'
29+
>,
30+
);
31+
},
32+
)
33+
.command(
34+
'gei',
35+
'Create a integration project',
36+
async (yargs) => {
37+
yargs.options(
38+
confOptions({
39+
...projectOptions,
40+
}),
41+
);
42+
},
43+
async (argv) => {
44+
await Auth.login().then(Config.setTokenOptions);
45+
await CommandBootstrapIntegration(
46+
argv as Pick<
47+
ConfigurationOptions,
48+
'project' | 'namespace' | 'projectVersion'
49+
>,
50+
);
51+
},
52+
);
3153
},
3254
} as CommandModule;
File renamed without changes.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
export default (integrationName: string) => `
2+
on:
3+
push:
4+
tags:
5+
- "[0-9]+.[0-9]+.[0-9]+"
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
# Setup .npmrc file to publish to npm
12+
- uses: actions/setup-node@v1
13+
with:
14+
node-version: "16.x"
15+
registry-url: "https://registry.npmjs.org"
16+
- run: npm install
17+
- run: npm run build -w ${integrationName}
18+
- run: npm publish --access public --tag latest -w ${integrationName}
19+
env:
20+
NODE_AUTH_TOKEN: \${{ secrets.NPM_AUTH_TOKEN }}
21+
`;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import deps from '@/deps.js';
2+
3+
export default (integrationName: string) => ({
4+
name: 'gei-workspace',
5+
version: '0.0.1',
6+
description: '',
7+
workspaces: ['./packages/integration', './packages/sandbox'],
8+
devDependencies: {
9+
'graphql-editor-cli': '^0.7.6',
10+
[integrationName]: '*',
11+
},
12+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export default {
2+
parser: '@typescript-eslint/parser',
3+
extends: [
4+
'plugin:@typescript-eslint/recommended',
5+
'plugin:prettier/recommended',
6+
],
7+
parserOptions: {
8+
ecmaVersion: 2018,
9+
sourceType: 'module',
10+
},
11+
plugins: ['@typescript-eslint', 'prettier'],
12+
rules: {
13+
'@typescript-eslint/explicit-function-return-type': 0,
14+
},
15+
};
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import deps from '@/deps.js';
2+
const { dependencies, devDependencies } = deps;
3+
4+
export default (integrationName: string) => ({
5+
name: integrationName,
6+
version: '0.0.1',
7+
description: 'Automatically generated by graphql-editor-cli',
8+
main: 'index.js',
9+
scripts: {
10+
start: 'gecli dev',
11+
build: 'tsc',
12+
watch: 'tsc --watch',
13+
update: 'gecli codegen models && gecli schema && gecli codegen typings',
14+
},
15+
author: 'GraphQL Editor Centaur Generator',
16+
license: 'ISC',
17+
type: 'module',
18+
devDependencies: {
19+
...devDependencies,
20+
},
21+
dependencies: {
22+
...dependencies,
23+
'graphql-editor-cli': '^0.7.6',
24+
},
25+
});
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default {
2+
arrowParens: 'always',
3+
semi: true,
4+
trailingComma: 'all',
5+
singleQuote: true,
6+
printWidth: 120,
7+
tabWidth: 2,
8+
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default {
2+
resolvers: {},
3+
};
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
export default {
2+
compilerOptions: {
3+
skipLibCheck: true,
4+
moduleResolution: 'node',
5+
target:
6+
'es2020' /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
7+
module:
8+
'es2020' /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
9+
declaration: true /* Generates corresponding '.d.ts' file. */,
10+
outDir: './lib' /* Redirect output structure to the directory. */,
11+
rootDir:
12+
'./src' /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */,
13+
strict: true /* Enable all strict type-checking options. */,
14+
strictNullChecks: true,
15+
esModuleInterop:
16+
true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
17+
},
18+
include: ['./src/**/*'],
19+
exclude: ['node_modules'],
20+
};

0 commit comments

Comments
 (0)