@smartive/graphql-magic 8.1.0 → 8.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/.eslintrc +1 -1
  2. package/CHANGELOG.md +3 -3
  3. package/dist/bin/gqm.cjs +1099 -1099
  4. package/dist/cjs/index.cjs +2 -521
  5. package/dist/esm/index.d.ts +0 -1
  6. package/dist/esm/index.js +0 -1
  7. package/dist/esm/index.js.map +1 -1
  8. package/package.json +3 -3
  9. package/src/bin/{gqm.ts → gqm/gqm.ts} +8 -8
  10. package/src/{gqm → bin/gqm}/parse-models.ts +1 -1
  11. package/src/{gqm → bin/gqm}/visitor.ts +1 -1
  12. package/src/index.ts +0 -1
  13. package/tsconfig.eslint.json +4 -0
  14. package/tsconfig.json +1 -1
  15. package/dist/esm/bin/gqm.d.ts +0 -2
  16. package/dist/esm/bin/gqm.js +0 -121
  17. package/dist/esm/bin/gqm.js.map +0 -1
  18. package/dist/esm/gqm/codegen.d.ts +0 -2
  19. package/dist/esm/gqm/codegen.js +0 -46
  20. package/dist/esm/gqm/codegen.js.map +0 -1
  21. package/dist/esm/gqm/index.d.ts +0 -9
  22. package/dist/esm/gqm/index.js +0 -11
  23. package/dist/esm/gqm/index.js.map +0 -1
  24. package/dist/esm/gqm/parse-knexfile.d.ts +0 -2
  25. package/dist/esm/gqm/parse-knexfile.js +0 -19
  26. package/dist/esm/gqm/parse-knexfile.js.map +0 -1
  27. package/dist/esm/gqm/parse-models.d.ts +0 -2
  28. package/dist/esm/gqm/parse-models.js +0 -19
  29. package/dist/esm/gqm/parse-models.js.map +0 -1
  30. package/dist/esm/gqm/readline.d.ts +0 -1
  31. package/dist/esm/gqm/readline.js +0 -14
  32. package/dist/esm/gqm/readline.js.map +0 -1
  33. package/dist/esm/gqm/settings.d.ts +0 -9
  34. package/dist/esm/gqm/settings.js +0 -98
  35. package/dist/esm/gqm/settings.js.map +0 -1
  36. package/dist/esm/gqm/static-eval.d.ts +0 -3
  37. package/dist/esm/gqm/static-eval.js +0 -188
  38. package/dist/esm/gqm/static-eval.js.map +0 -1
  39. package/dist/esm/gqm/templates.d.ts +0 -4
  40. package/dist/esm/gqm/templates.js +0 -62
  41. package/dist/esm/gqm/templates.js.map +0 -1
  42. package/dist/esm/gqm/utils.d.ts +0 -2
  43. package/dist/esm/gqm/utils.js +0 -22
  44. package/dist/esm/gqm/utils.js.map +0 -1
  45. package/dist/esm/gqm/visitor.d.ts +0 -8
  46. package/dist/esm/gqm/visitor.js +0 -15
  47. package/dist/esm/gqm/visitor.js.map +0 -1
  48. package/src/gqm/index.ts +0 -11
  49. /package/src/{gqm → bin/gqm}/codegen.ts +0 -0
  50. /package/src/{gqm → bin/gqm}/parse-knexfile.ts +0 -0
  51. /package/src/{gqm → bin/gqm}/readline.ts +0 -0
  52. /package/src/{gqm → bin/gqm}/settings.ts +0 -0
  53. /package/src/{gqm → bin/gqm}/static-eval.ts +0 -0
  54. /package/src/{gqm → bin/gqm}/templates.ts +0 -0
  55. /package/src/{gqm → bin/gqm}/utils.ts +0 -0
@@ -11,13 +11,13 @@ import {
11
11
  generateMutations,
12
12
  getMigrationDate,
13
13
  printSchemaFromModels,
14
- } from '..';
15
- import { generateGraphqlApiTypes, generateGraphqlClientTypes } from '../gqm/codegen';
16
- import { KNEXFILE_PATH, parseKnexfile } from '../gqm/parse-knexfile';
17
- import { parseModels } from '../gqm/parse-models';
18
- import { readLine } from '../gqm/readline';
19
- import { ensureFileExists, getSetting, getSettings, writeToFile } from '../gqm/settings';
20
- import { KNEXFILE } from '../gqm/templates';
14
+ } from '../..';
15
+ import { generateGraphqlApiTypes, generateGraphqlClientTypes } from './codegen';
16
+ import { KNEXFILE_PATH, parseKnexfile } from './parse-knexfile';
17
+ import { parseModels } from './parse-models';
18
+ import { readLine } from './readline';
19
+ import { ensureFileExists, getSetting, getSettings, writeToFile } from './settings';
20
+ import { KNEXFILE } from './templates';
21
21
 
22
22
  config({
23
23
  path: '.env',
@@ -115,7 +115,7 @@ program
115
115
  .action(async () => {
116
116
  const git = simpleGit();
117
117
 
118
- let name = process.argv[2] || (await git.branch()).current.split('/').pop();
118
+ let name = process.argv[process.argv.indexOf('gqm') + 1] || (await git.branch()).current.split('/').pop();
119
119
 
120
120
  if (name && ['staging', 'production'].includes(name)) {
121
121
  name = await readLine('Migration name:');
@@ -1,5 +1,5 @@
1
1
  import { IndentationText, Project } from 'ts-morph';
2
- import { RawModels } from '..';
2
+ import { RawModels } from '../..';
3
3
  import { getSetting, writeToFile } from './settings';
4
4
  import { staticEval } from './static-eval';
5
5
  import { findDeclarationInFile } from './utils';
@@ -1,5 +1,5 @@
1
1
  import { KindToNodeMappings, Node, SyntaxKind } from 'ts-morph';
2
- import { get } from '..';
2
+ import { get } from '../..';
3
3
 
4
4
  export type Visitor<T, C> = {
5
5
  undefined?: () => T;
package/src/index.ts CHANGED
@@ -3,7 +3,6 @@
3
3
  export * from './api';
4
4
  export * from './client';
5
5
  export * from './db';
6
- export * from './gqm';
7
6
  export * from './migrations';
8
7
  export * from './models';
9
8
  export * from './permissions';
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "exclude": ["node_modules", "dist"],
4
+ }
package/tsconfig.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "include": ["./src/**/*.ts", "./src/**/*.tsx"],
3
- "exclude": ["node_modules", "dist"],
3
+ "exclude": ["node_modules", "dist", "src/bin"],
4
4
  "compilerOptions": {
5
5
  "outDir": "./dist/esm",
6
6
  "rootDir": "./src",
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
@@ -1,121 +0,0 @@
1
- #!/usr/bin/env node
2
- import { program } from 'commander';
3
- import { config } from 'dotenv';
4
- import knex from 'knex';
5
- import { simpleGit } from 'simple-git';
6
- import { MigrationGenerator, generateDBModels, generateKnexTables, generateMutations, getMigrationDate, printSchemaFromModels, } from '..';
7
- import { generateGraphqlApiTypes, generateGraphqlClientTypes } from '../gqm/codegen';
8
- import { KNEXFILE_PATH, parseKnexfile } from '../gqm/parse-knexfile';
9
- import { parseModels } from '../gqm/parse-models';
10
- import { readLine } from '../gqm/readline';
11
- import { ensureFileExists, getSetting, getSettings, writeToFile } from '../gqm/settings';
12
- import { KNEXFILE } from '../gqm/templates';
13
- config({
14
- path: '.env',
15
- });
16
- config({
17
- path: '.env.local',
18
- });
19
- program.description('The graphql-magic cli.');
20
- program
21
- .command('setup')
22
- .description('Set up the project')
23
- .action(async () => {
24
- await getSettings();
25
- ensureFileExists(KNEXFILE_PATH, KNEXFILE);
26
- });
27
- program
28
- .command('generate')
29
- .description('Generate all the things')
30
- .action(async () => {
31
- const rawModels = await parseModels();
32
- const generatedFolderPath = await getSetting('generatedFolderPath');
33
- writeToFile(`${generatedFolderPath}/schema.graphql`, printSchemaFromModels(rawModels));
34
- writeToFile(`${generatedFolderPath}/client/mutations.ts`, generateMutations(rawModels));
35
- writeToFile(`${generatedFolderPath}/db/index.ts`, generateDBModels(rawModels));
36
- writeToFile(`${generatedFolderPath}/db/knex.ts`, generateKnexTables(rawModels));
37
- await generateGraphqlApiTypes();
38
- await generateGraphqlClientTypes();
39
- });
40
- program
41
- .command('generate-models')
42
- .description('Generate models.json')
43
- .action(async () => {
44
- const rawModels = await parseModels();
45
- const generatedFolderPath = await getSetting('generatedFolderPath');
46
- writeToFile(`${generatedFolderPath}/models.json`, JSON.stringify(rawModels, null, 2));
47
- });
48
- program
49
- .command('generate-schema')
50
- .description('Generate schema')
51
- .action(async () => {
52
- const rawModels = await parseModels();
53
- const generatedFolderPath = await getSetting('generatedFolderPath');
54
- writeToFile(`${generatedFolderPath}/schema.graphql`, printSchemaFromModels(rawModels));
55
- });
56
- program
57
- .command('generate-mutation-queries')
58
- .description('Generate mutation-queries')
59
- .action(async () => {
60
- const rawModels = await parseModels();
61
- const generatedFolderPath = await getSetting('generatedFolderPath');
62
- writeToFile(`${generatedFolderPath}/client/mutations.ts`, generateMutations(rawModels));
63
- });
64
- program
65
- .command('generate-db-types')
66
- .description('Generate DB types')
67
- .action(async () => {
68
- const rawModels = await parseModels();
69
- const generatedFolderPath = await getSetting('generatedFolderPath');
70
- writeToFile(`${generatedFolderPath}/db/index.ts`, generateMutations(rawModels));
71
- });
72
- program
73
- .command('generate-knex-types')
74
- .description('Generate Knex types')
75
- .action(async () => {
76
- const rawModels = await parseModels();
77
- const generatedFolderPath = await getSetting('generatedFolderPath');
78
- writeToFile(`${generatedFolderPath}/db/knex.ts`, generateKnexTables(rawModels));
79
- });
80
- program
81
- .command('generate-graphql-api-types')
82
- .description('Generate Graphql API types')
83
- .action(async () => {
84
- await generateGraphqlApiTypes();
85
- });
86
- program
87
- .command('generate-graphql-client-types')
88
- .description('Generate Graphql client types')
89
- .action(async () => {
90
- await generateGraphqlClientTypes();
91
- });
92
- program
93
- .command('generate-migration')
94
- .description('Generate Migration')
95
- .action(async () => {
96
- const git = simpleGit();
97
- let name = process.argv[2] || (await git.branch()).current.split('/').pop();
98
- if (name && ['staging', 'production'].includes(name)) {
99
- name = await readLine('Migration name:');
100
- }
101
- const knexfile = await parseKnexfile();
102
- const db = knex(knexfile);
103
- try {
104
- const rawModels = await parseModels();
105
- const migrations = await new MigrationGenerator(db, rawModels).generate();
106
- writeToFile(`migrations/${getMigrationDate()}_${name}.ts`, migrations);
107
- }
108
- finally {
109
- await db.destroy();
110
- }
111
- });
112
- program
113
- .command('*', { noHelp: true })
114
- .description('Invalid command')
115
- .action(() => {
116
- console.error('Invalid command: %s\nSee --help for a list of available commands.', program.args.join(' '));
117
- process.exit(1);
118
- });
119
- // Parse the arguments
120
- program.parse(process.argv);
121
- //# sourceMappingURL=gqm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"gqm.js","sourceRoot":"","sources":["../../../src/bin/gqm.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ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ACtB,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare const generateGraphqlApiTypes: () => Promise<void>;
2
- export declare const generateGraphqlClientTypes: () => Promise<void>;
@@ -1,46 +0,0 @@
1
- import { generate } from '@graphql-codegen/cli';
2
- import { getSetting } from './settings';
3
- export const generateGraphqlApiTypes = async () => {
4
- const generatedFolderPath = await getSetting('generatedFolderPath');
5
- await generate({
6
- overwrite: true,
7
- schema: `${generatedFolderPath}/schema.graphql`,
8
- documents: null,
9
- generates: {
10
- [`${generatedFolderPath}/api/index.ts`]: {
11
- plugins: ['typescript', 'typescript-resolvers', { add: { content: `import { DateTime } from 'luxon';` } }],
12
- },
13
- },
14
- config: {
15
- scalars: {
16
- DateTime: 'DateTime',
17
- },
18
- },
19
- });
20
- };
21
- export const generateGraphqlClientTypes = async () => {
22
- const generatedFolderPath = await getSetting('generatedFolderPath');
23
- await generate({
24
- schema: `${generatedFolderPath}/schema.graphql`,
25
- documents: ['./src/**/*.ts', './src/**/*.tsx'],
26
- generates: {
27
- [`${generatedFolderPath}/client/index.ts`]: {
28
- plugins: ['typescript', 'typescript-operations', 'typescript-compatibility'],
29
- },
30
- },
31
- config: {
32
- preResolveTypes: true,
33
- namingConvention: 'keep',
34
- nonOptionalTypename: true,
35
- skipTypeNameForRoot: true,
36
- avoidOptionals: {
37
- // Avoids optionals on the level of the field
38
- field: true,
39
- },
40
- scalars: {
41
- DateTime: 'string',
42
- },
43
- },
44
- });
45
- };
46
- //# sourceMappingURL=codegen.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"codegen.js","sourceRoot":"","sources":["../../../src/gqm/codegen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,IAAI,EAAE;IAChD,MAAM,mBAAmB,GAAG,MAAM,UAAU,CAAC,qBAAqB,CAAC,CAAC;IACpE,MAAM,QAAQ,CAAC;QACb,SAAS,EAAE,IAAI;QACf,MAAM,EAAE,GAAG,mBAAmB,iBAAiB;QAC/C,SAAS,EAAE,IAAI;QACf,SAAS,EAAE;YACT,CAAC,GAAG,mBAAmB,eAAe,CAAC,EAAE;gBACvC,OAAO,EAAE,CAAC,YAAY,EAAE,sBAAsB,EAAE,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,mCAAmC,EAAE,EAAE,CAAC;aAC3G;SACF;QACD,MAAM,EAAE;YACN,OAAO,EAAE;gBACP,QAAQ,EAAE,UAAU;aACrB;SACF;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,0BAA0B,GAAG,KAAK,IAAI,EAAE;IACnD,MAAM,mBAAmB,GAAG,MAAM,UAAU,CAAC,qBAAqB,CAAC,CAAC;IACpE,MAAM,QAAQ,CAAC;QACb,MAAM,EAAE,GAAG,mBAAmB,iBAAiB;QAC/C,SAAS,EAAE,CAAC,eAAe,EAAE,gBAAgB,CAAC;QAC9C,SAAS,EAAE;YACT,CAAC,GAAG,mBAAmB,kBAAkB,CAAC,EAAE;gBAC1C,OAAO,EAAE,CAAC,YAAY,EAAE,uBAAuB,EAAE,0BAA0B,CAAC;aAC7E;SACF;QACD,MAAM,EAAE;YACN,eAAe,EAAE,IAAI;YACrB,gBAAgB,EAAE,MAAM;YACxB,mBAAmB,EAAE,IAAI;YACzB,mBAAmB,EAAE,IAAI;YACzB,cAAc,EAAE;gBACd,6CAA6C;gBAC7C,KAAK,EAAE,IAAI;aACZ;YACD,OAAO,EAAE;gBACP,QAAQ,EAAE,QAAQ;aACnB;SACF;KACF,CAAC,CAAC;AACL,CAAC,CAAC"}
@@ -1,9 +0,0 @@
1
- export * from './codegen';
2
- export * from './parse-knexfile';
3
- export * from './parse-models';
4
- export * from './readline';
5
- export * from './settings';
6
- export * from './static-eval';
7
- export * from './templates';
8
- export * from './utils';
9
- export * from './visitor';
@@ -1,11 +0,0 @@
1
- // created from 'create-ts-index'
2
- export * from './codegen';
3
- export * from './parse-knexfile';
4
- export * from './parse-models';
5
- export * from './readline';
6
- export * from './settings';
7
- export * from './static-eval';
8
- export * from './templates';
9
- export * from './utils';
10
- export * from './visitor';
11
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/gqm/index.ts"],"names":[],"mappings":"AAAA,iCAAiC;AAEjC,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare const KNEXFILE_PATH = "knexfile.ts";
2
- export declare const parseKnexfile: () => Promise<unknown>;
@@ -1,19 +0,0 @@
1
- import { IndentationText, Project } from 'ts-morph';
2
- import { ensureFileExists } from './settings';
3
- import { staticEval } from './static-eval';
4
- import { KNEXFILE } from './templates';
5
- import { findDeclarationInFile } from './utils';
6
- export const KNEXFILE_PATH = `knexfile.ts`;
7
- export const parseKnexfile = async () => {
8
- const project = new Project({
9
- manipulationSettings: {
10
- indentationText: IndentationText.TwoSpaces,
11
- },
12
- });
13
- ensureFileExists(KNEXFILE_PATH, KNEXFILE);
14
- const sourceFile = project.addSourceFileAtPath(KNEXFILE_PATH);
15
- const configDeclaration = findDeclarationInFile(sourceFile, 'config');
16
- const config = staticEval(configDeclaration, {});
17
- return config;
18
- };
19
- //# sourceMappingURL=parse-knexfile.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parse-knexfile.js","sourceRoot":"","sources":["../../../src/gqm/parse-knexfile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAEhD,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAC;AAE3C,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,IAAI,EAAE;IACtC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC;QAC1B,oBAAoB,EAAE;YACpB,eAAe,EAAE,eAAe,CAAC,SAAS;SAC3C;KACF,CAAC,CAAC;IACH,gBAAgB,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;IAE1C,MAAM,UAAU,GAAG,OAAO,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC;IAC9D,MAAM,iBAAiB,GAAG,qBAAqB,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IACtE,MAAM,MAAM,GAAG,UAAU,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;IACjD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- import { RawModels } from '..';
2
- export declare const parseModels: () => Promise<RawModels>;
@@ -1,19 +0,0 @@
1
- import { IndentationText, Project } from 'ts-morph';
2
- import { getSetting, writeToFile } from './settings';
3
- import { staticEval } from './static-eval';
4
- import { findDeclarationInFile } from './utils';
5
- export const parseModels = async () => {
6
- const project = new Project({
7
- manipulationSettings: {
8
- indentationText: IndentationText.TwoSpaces,
9
- },
10
- });
11
- const modelsPath = await getSetting('modelsPath');
12
- const sourceFile = project.addSourceFileAtPath(modelsPath);
13
- const modelsDeclaration = findDeclarationInFile(sourceFile, 'rawModels');
14
- const rawModels = staticEval(modelsDeclaration, {});
15
- const generatedFolderPath = await getSetting('generatedFolderPath');
16
- writeToFile(`${generatedFolderPath}/models.json`, JSON.stringify(rawModels, null, 2));
17
- return rawModels;
18
- };
19
- //# sourceMappingURL=parse-models.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parse-models.js","sourceRoot":"","sources":["../../../src/gqm/parse-models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAEhD,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,IAAI,EAAE;IACpC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC;QAC1B,oBAAoB,EAAE;YACpB,eAAe,EAAE,eAAe,CAAC,SAAS;SAC3C;KACF,CAAC,CAAC;IACH,MAAM,UAAU,GAAG,MAAM,UAAU,CAAC,YAAY,CAAC,CAAC;IAClD,MAAM,UAAU,GAAG,OAAO,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAE3D,MAAM,iBAAiB,GAAG,qBAAqB,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;IAEzE,MAAM,SAAS,GAAG,UAAU,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;IAEpD,MAAM,mBAAmB,GAAG,MAAM,UAAU,CAAC,qBAAqB,CAAC,CAAC;IACpE,WAAW,CAAC,GAAG,mBAAmB,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAEtF,OAAO,SAAsB,CAAC;AAChC,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- export declare const readLine: (prompt: string) => Promise<string>;
@@ -1,14 +0,0 @@
1
- import readline from 'readline';
2
- export const readLine = (prompt) => {
3
- const rl = readline.createInterface({
4
- input: process.stdin,
5
- output: process.stdout,
6
- });
7
- return new Promise((resolve) => {
8
- rl.question(prompt, (answer) => {
9
- rl.close();
10
- resolve(answer);
11
- });
12
- });
13
- };
14
- //# sourceMappingURL=readline.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"readline.js","sourceRoot":"","sources":["../../../src/gqm/readline.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,MAAc,EAAmB,EAAE;IAC1D,MAAM,EAAE,GAAG,QAAQ,CAAC,eAAe,CAAC;QAClC,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,CAAC,CAAC;IAEH,OAAO,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,EAAE;QACrC,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE;YAC7B,EAAE,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,CAAC,MAAM,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
@@ -1,9 +0,0 @@
1
- type Settings = {
2
- modelsPath: string;
3
- generatedFolderPath: string;
4
- };
5
- export declare const getSettings: () => Promise<Settings>;
6
- export declare const getSetting: (name: keyof Settings) => Promise<string>;
7
- export declare const ensureFileExists: (filePath: string, content: string) => void;
8
- export declare const writeToFile: (filePath: string, content: string) => void;
9
- export {};
@@ -1,98 +0,0 @@
1
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
2
- import { dirname } from 'path';
3
- import { readLine } from './readline';
4
- import { CLIENT_CODEGEN, EMPTY_MODELS, GRAPHQL_CODEGEN } from './templates';
5
- const SETTINGS_PATH = '.gqmrc.json';
6
- const DEFAULTS = {
7
- modelsPath: {
8
- question: 'What is the models path?',
9
- defaultValue: 'src/config/models.ts',
10
- init: (path) => {
11
- ensureFileExists(path, EMPTY_MODELS);
12
- },
13
- },
14
- generatedFolderPath: {
15
- question: 'What is the path for generated stuff?',
16
- defaultValue: 'src/generated',
17
- init: (path) => {
18
- ensureFileExists(`${path}/.gitkeep`, '');
19
- ensureFileExists(`${path}/db/.gitkeep`, '');
20
- ensureFileExists(`${path}/api/.gitkeep`, '');
21
- ensureFileExists(`${path}/client/.gitkeep`, '');
22
- ensureFileExists(`graphql-codegen.yml`, GRAPHQL_CODEGEN(path));
23
- ensureFileExists(`client-codegen.yml`, CLIENT_CODEGEN(path));
24
- },
25
- },
26
- };
27
- const initSetting = async (name) => {
28
- const { question, defaultValue, init } = DEFAULTS[name];
29
- const value = (await readLine(`${question} (${defaultValue})`)) || defaultValue;
30
- init(value);
31
- return value;
32
- };
33
- const initSettings = async () => {
34
- const settings = {};
35
- for (const name of Object.keys(DEFAULTS)) {
36
- settings[name] = await initSetting(name);
37
- }
38
- saveSettings(settings);
39
- };
40
- const saveSettings = (settings) => {
41
- writeToFile(SETTINGS_PATH, JSON.stringify(settings, null, 2));
42
- };
43
- export const getSettings = async () => {
44
- if (!existsSync(SETTINGS_PATH)) {
45
- await initSettings();
46
- }
47
- return JSON.parse(readFileSync(SETTINGS_PATH, 'utf8'));
48
- };
49
- export const getSetting = async (name) => {
50
- const settings = await getSettings();
51
- if (!(name in settings)) {
52
- settings[name] = await initSetting(name);
53
- saveSettings(settings);
54
- }
55
- return settings[name];
56
- };
57
- const ensureDirectoryExists = (filePath) => {
58
- const dir = dirname(filePath);
59
- if (existsSync(dir)) {
60
- return true;
61
- }
62
- ensureDirectoryExists(dir);
63
- try {
64
- mkdirSync(dir);
65
- return true;
66
- }
67
- catch (err) {
68
- if (err.code === 'EEXIST') {
69
- return true;
70
- }
71
- throw err;
72
- }
73
- };
74
- export const ensureFileExists = (filePath, content) => {
75
- if (!existsSync(filePath)) {
76
- console.info(`Creating ${filePath}`);
77
- ensureDirectoryExists(filePath);
78
- writeFileSync(filePath, content);
79
- }
80
- };
81
- export const writeToFile = (filePath, content) => {
82
- ensureDirectoryExists(filePath);
83
- if (existsSync(filePath)) {
84
- const currentContent = readFileSync(filePath, 'utf-8');
85
- if (content === currentContent) {
86
- // console.info(`${filePath} unchanged`);
87
- }
88
- else {
89
- writeFileSync(filePath, content);
90
- console.info(`${filePath} updated`);
91
- }
92
- }
93
- else {
94
- writeFileSync(filePath, content);
95
- console.info(`Created ${filePath}`);
96
- }
97
- };
98
- //# sourceMappingURL=settings.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"settings.js","sourceRoot":"","sources":["../../../src/gqm/settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE5E,MAAM,aAAa,GAAG,aAAa,CAAC;AAEpC,MAAM,QAAQ,GAAG;IACf,UAAU,EAAE;QACV,QAAQ,EAAE,0BAA0B;QACpC,YAAY,EAAE,sBAAsB;QACpC,IAAI,EAAE,CAAC,IAAY,EAAE,EAAE;YACrB,gBAAgB,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;QACvC,CAAC;KACF;IACD,mBAAmB,EAAE;QACnB,QAAQ,EAAE,uCAAuC;QACjD,YAAY,EAAE,eAAe;QAC7B,IAAI,EAAE,CAAC,IAAY,EAAE,EAAE;YACrB,gBAAgB,CAAC,GAAG,IAAI,WAAW,EAAE,EAAE,CAAC,CAAC;YACzC,gBAAgB,CAAC,GAAG,IAAI,cAAc,EAAE,EAAE,CAAC,CAAC;YAC5C,gBAAgB,CAAC,GAAG,IAAI,eAAe,EAAE,EAAE,CAAC,CAAC;YAC7C,gBAAgB,CAAC,GAAG,IAAI,kBAAkB,EAAE,EAAE,CAAC,CAAC;YAChD,gBAAgB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G,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACvD,IAAI,OAAO,KAAK,cAAc,EAAE;YAC9B,yCAAyC;SAC1C;aAAM;YACL,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YACjC,OAAO,CAAC,IAAI,CAAC,GAAG,QAAQ,UAAU,CAAC,CAAC;SACrC;KACF;SAAM;QACL,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACjC,OAAO,CAAC,IAAI,CAAC,WAAW,QAAQ,EAAE,CAAC,CAAC;KACrC;AACH,CAAC,CAAC"}
@@ -1,3 +0,0 @@
1
- import { Dictionary } from 'lodash';
2
- import { Node } from 'ts-morph';
3
- export declare const staticEval: (node: Node, context: Dictionary<unknown>) => unknown;