@common-stack/generate-plugin 5.0.4-alpha.5 → 5.0.4-alpha.9

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 (67) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/generators.json +4 -4
  3. package/lib/generators/add-frontend/generator.cjs +38 -0
  4. package/lib/generators/add-frontend/generator.cjs.map +1 -0
  5. package/lib/generators/add-frontend/generator.d.ts +4 -0
  6. package/lib/generators/add-frontend/generator.mjs +38 -0
  7. package/lib/generators/add-frontend/generator.mjs.map +1 -0
  8. package/lib/generators/add-frontend/schema.json +21 -0
  9. package/lib/generators/add-frontend/templates/Dockerfile +30 -0
  10. package/lib/generators/add-frontend/templates/codecept.json +28 -0
  11. package/lib/generators/add-frontend/templates/config.json +58 -0
  12. package/lib/generators/add-frontend/templates/env.d.ts.template +9 -0
  13. package/lib/generators/add-frontend/templates/env.js +5 -0
  14. package/lib/generators/add-frontend/templates/favicon.ico +0 -0
  15. package/lib/generators/add-frontend/templates/jest.config.js +33 -0
  16. package/lib/generators/add-frontend/templates/package.json +183 -0
  17. package/lib/generators/add-frontend/templates/public/css/dashboard.css +491 -0
  18. package/lib/generators/add-frontend/templates/public/favicon.ico +0 -0
  19. package/lib/generators/add-frontend/templates/server.js +78 -0
  20. package/lib/generators/add-frontend/templates/src/config/public-config.ts.template +82 -0
  21. package/lib/generators/add-frontend/templates/tools/mergeConfig.js +34 -0
  22. package/lib/generators/add-frontend/templates/tsconfig.base.json +38 -0
  23. package/lib/generators/add-frontend/templates/tsconfig.json +32 -0
  24. package/lib/generators/add-frontend/templates/tsconfig.node.json +10 -0
  25. package/lib/generators/add-frontend/templates/vite.config.ts.template +70 -0
  26. package/lib/index.cjs +1 -1
  27. package/lib/index.d.ts +1 -1
  28. package/lib/index.mjs +1 -1
  29. package/package.json +2 -2
  30. package/rollup.config.mjs +12 -5
  31. package/src/generators/{add-entries → add-frontend}/generator.spec.ts +5 -5
  32. package/src/generators/add-frontend/generator.ts +50 -0
  33. package/src/generators/add-frontend/schema.d.ts +5 -0
  34. package/src/generators/add-frontend/schema.json +21 -0
  35. package/src/index.ts +2 -2
  36. package/lib/generators/add-entries/generator.cjs +0 -55
  37. package/lib/generators/add-entries/generator.cjs.map +0 -1
  38. package/lib/generators/add-entries/generator.d.ts +0 -4
  39. package/lib/generators/add-entries/generator.mjs +0 -55
  40. package/lib/generators/add-entries/generator.mjs.map +0 -1
  41. package/lib/generators/add-entries/schema.json +0 -13
  42. package/src/generators/add-entries/files/common/AntStyles.tsx.template +0 -8
  43. package/src/generators/add-entries/files/common/createEmotionCache.ts.template +0 -7
  44. package/src/generators/add-entries/files/common/index.ts.template +0 -3
  45. package/src/generators/add-entries/files/common/utils.ts.template +0 -16
  46. package/src/generators/add-entries/generator.ts +0 -66
  47. package/src/generators/add-entries/schema.d.ts +0 -3
  48. package/src/generators/add-entries/schema.json +0 -13
  49. /package/lib/generators/{add-entries/entries → add-frontend/frameworks}/antui/entry.client.tsx.template +0 -0
  50. /package/lib/generators/{add-entries/entries → add-frontend/frameworks}/antui/entry.server.tsx.template +0 -0
  51. /package/lib/generators/{add-entries/entries → add-frontend/frameworks}/antui/root.tsx.template +0 -0
  52. /package/lib/generators/{add-entries/entries → add-frontend/frameworks}/chakraui/context.tsx.template +0 -0
  53. /package/lib/generators/{add-entries/entries → add-frontend/frameworks}/chakraui/entry.client.tsx.template +0 -0
  54. /package/lib/generators/{add-entries/entries → add-frontend/frameworks}/chakraui/entry.server.tsx.template +0 -0
  55. /package/lib/generators/{add-entries/entries → add-frontend/frameworks}/chakraui/root.tsx.template +0 -0
  56. /package/lib/generators/{add-entries → add-frontend}/generator.spec.d.ts +0 -0
  57. /package/lib/generators/{add-entries/files → add-frontend/templates/src}/common/AntStyles.tsx.template +0 -0
  58. /package/lib/generators/{add-entries/files → add-frontend/templates/src}/common/createEmotionCache.ts.template +0 -0
  59. /package/lib/generators/{add-entries/files → add-frontend/templates/src}/common/index.ts.template +0 -0
  60. /package/lib/generators/{add-entries/files → add-frontend/templates/src}/common/utils.ts.template +0 -0
  61. /package/src/generators/{add-entries/entries → add-frontend/frameworks}/antui/entry.client.tsx.template +0 -0
  62. /package/src/generators/{add-entries/entries → add-frontend/frameworks}/antui/entry.server.tsx.template +0 -0
  63. /package/src/generators/{add-entries/entries → add-frontend/frameworks}/antui/root.tsx.template +0 -0
  64. /package/src/generators/{add-entries/entries → add-frontend/frameworks}/chakraui/context.tsx.template +0 -0
  65. /package/src/generators/{add-entries/entries → add-frontend/frameworks}/chakraui/entry.client.tsx.template +0 -0
  66. /package/src/generators/{add-entries/entries → add-frontend/frameworks}/chakraui/entry.server.tsx.template +0 -0
  67. /package/src/generators/{add-entries/entries → add-frontend/frameworks}/chakraui/root.tsx.template +0 -0
@@ -0,0 +1,38 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "ES2022",
5
+ "moduleResolution": "NodeNext",
6
+ "esModuleInterop": true,
7
+ "jsx": "react",
8
+ "skipLibCheck": true,
9
+ "declaration": true,
10
+ "experimentalDecorators": true,
11
+ "emitDecoratorMetadata": true,
12
+ "preserveConstEnums": true,
13
+ "sourceMap": true,
14
+ "noImplicitAny": false,
15
+ "allowSyntheticDefaultImports": true,
16
+ "pretty": true,
17
+ "removeComments": false,
18
+ "lib": [
19
+ "ES2020",
20
+ "dom",
21
+ "esnext.asynciterable"
22
+ ],
23
+ "typeRoots": [
24
+ "./typings/*.d.ts",
25
+ "node_modules/@types"
26
+ ],
27
+ "types": [
28
+ "@types/node",
29
+ "@types/jest"
30
+ ]
31
+ },
32
+ "include": [
33
+ "./typings/*.d.ts"
34
+ ],
35
+ "exclude": [
36
+ "node_modules"
37
+ ]
38
+ }
@@ -0,0 +1,32 @@
1
+ {
2
+ "include": [
3
+ "**/*.ts",
4
+ "**/*.tsx",
5
+ "**/.server/**/*.ts",
6
+ "**/.server/**/*.tsx",
7
+ "**/.client/**/*.ts",
8
+ "**/.client/**/*.tsx"
9
+ ],
10
+ "compilerOptions": {
11
+ "lib": ["DOM", "DOM.Iterable", "ES2022"],
12
+ "types": ["@remix-run/node", "vite/client"],
13
+ "isolatedModules": true,
14
+ "esModuleInterop": true,
15
+ "jsx": "react-jsx",
16
+ "module": "ESNext",
17
+ "moduleResolution": "Bundler",
18
+ "resolveJsonModule": true,
19
+ "target": "ES2022",
20
+ "strict": true,
21
+ "allowJs": true,
22
+ "skipLibCheck": true,
23
+ "forceConsistentCasingInFileNames": true,
24
+ "baseUrl": ".",
25
+ "paths": {
26
+ "~/*": ["./src/*"]
27
+ },
28
+
29
+ // Vite takes care of building everything, not tsc.
30
+ "noEmit": true
31
+ }
32
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "compilerOptions": {
3
+ "composite": true,
4
+ "skipLibCheck": true,
5
+ "module": "ESNext",
6
+ "moduleResolution": "bundler",
7
+ "allowSyntheticDefaultImports": true
8
+ },
9
+ "include": ["vite.config.ts"]
10
+ }
@@ -0,0 +1,70 @@
1
+ import { defineConfig } from 'vite';
2
+ import { vitePlugin as remix } from '@remix-run/dev';
3
+ import { dirname, resolve } from 'path';
4
+ import { installGlobals } from '@remix-run/node';
5
+ import { fileURLToPath } from 'url';
6
+ import { defineRoutesConfig } from '@common-stack/rollup-vite-utils/lib/vite-wrappers/json-wrappers.js';
7
+ import tsconfigPaths from 'vite-tsconfig-paths';
8
+ import { i18nInternationalizationPlugin } from '@common-stack/rollup-vite-utils/lib/vite-plugins/i18n-internationalization-plugin.js';
9
+ import { performCopyOperations } from '@common-stack/rollup-vite-utils/lib/preStartup/configLoader/configLoader.js';
10
+ import { loadEnvConfig } from '@common-stack/rollup-vite-utils/lib/preStartup/configLoader/envLoader.js';
11
+ import { cjsInterop } from 'vite-plugin-cjs-interop';
12
+ import config from './app/cde-webconfig.json' assert { type: 'json' };
13
+
14
+ // This installs globals such as "fetch", "Response", "Request" and "Headers".
15
+ installGlobals();
16
+ const directoryName = dirname(fileURLToPath(import.meta.url));
17
+
18
+ export default defineConfig(({ isSsrBuild }) => {
19
+ console.log('---IS SSR BUILD', isSsrBuild);
20
+
21
+ const dotEnvResult = loadEnvConfig(directoryName);
22
+
23
+ return {
24
+ define: {
25
+ __ENV__: JSON.stringify(dotEnvResult?.parsed),
26
+ ...Object.assign(
27
+ ...Object.entries(config.buildConfig).map(([k, v]) => ({
28
+ [k]: typeof v !== 'string' ? v : `"${v.replace(/\\/g, '\\\\')}"`,
29
+ __SERVER__: true,
30
+ __CLIENT__: false,
31
+ }))
32
+ ),
33
+ },
34
+ plugins: [
35
+ i18nInternationalizationPlugin({
36
+ folderName: 'cdm-locales',
37
+ packages: [...config.modules, ...config.i18n.packages],
38
+ namespaceResolution: 'basename',
39
+ }),
40
+ cjsInterop({
41
+ dependencies:["@apollo/client"]
42
+ }),
43
+ remix({
44
+ appDirectory: 'src',
45
+ routes: async (defineRoutes) => {
46
+ if (process.env.NODE_ENV === 'production') {
47
+ await performCopyOperations(config);
48
+ }
49
+ const metaJson = await import('./app/sync-meta.json').catch(() => null);
50
+ return defineRoutes((routeFn) => {
51
+ defineRoutesConfig(routeFn, {
52
+ routesFileName: 'routes.json',
53
+ packages: config.modules,
54
+ paths: config.paths,
55
+ rootPath: resolve(directoryName, '../..'),
56
+ }, metaJson);
57
+ });
58
+ },
59
+ }),
60
+ tsconfigPaths({ ignoreConfigErrors: true }),
61
+ ],
62
+ resolve: {
63
+ // preserveSymlinks: true,
64
+ alias: {
65
+ '@app': resolve(__dirname, 'app'),
66
+ '@src': resolve(__dirname, 'src'),
67
+ },
68
+ },
69
+ };
70
+ });
package/lib/index.cjs CHANGED
@@ -1 +1 @@
1
- 'use strict';var generator=require('./generators/add-entries/generator.cjs');exports.addEntriesGenerator=generator.addEntriesGenerator;//# sourceMappingURL=index.cjs.map
1
+ 'use strict';var generator=require('./generators/add-frontend/generator.cjs');exports.addFrontendGenerator=generator.addFrontendGenerator;//# sourceMappingURL=index.cjs.map
package/lib/index.d.ts CHANGED
@@ -1 +1 @@
1
- export * from './generators/add-entries/generator';
1
+ export * from './generators/add-frontend/generator';
package/lib/index.mjs CHANGED
@@ -1 +1 @@
1
- export{addEntriesGenerator}from'./generators/add-entries/generator.mjs';//# sourceMappingURL=index.mjs.map
1
+ export{addFrontendGenerator}from'./generators/add-frontend/generator.mjs';//# sourceMappingURL=index.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@common-stack/generate-plugin",
3
- "version": "5.0.4-alpha.5",
3
+ "version": "5.0.4-alpha.9",
4
4
  "type": "module",
5
5
  "main": "./lib/index.mjs",
6
6
  "typings": "./lib/index.d.ts",
@@ -24,5 +24,5 @@
24
24
  "tslib": "^2.3.0"
25
25
  },
26
26
  "generators": "./generators.json",
27
- "gitHead": "46efe10f26e4d35dadc8c84b76d373bc1eb1b8da"
27
+ "gitHead": "a160ae96828be333c8f0d5fca27709c0563be6a7"
28
28
  }
package/rollup.config.mjs CHANGED
@@ -7,19 +7,26 @@ import copy from 'rollup-plugin-copy';
7
7
  // Define a base configuration for reuse
8
8
  const baseConfig = {
9
9
  plugins: [
10
- image(),
10
+ image({
11
+ exclude: 'src/generators/add-frontend',
12
+ }),
11
13
  graphql({
12
14
  include: '**/*.gql',
15
+ exclude: 'src/generators/add-frontend',
13
16
  }),
14
17
  string({
15
18
  include: '**/*.graphql',
19
+ exclude: 'src/generators/add-frontend',
20
+ }),
21
+ typescript({
22
+ noEmitOnError: true,
23
+ exclude: 'src/generators/add-frontend',
16
24
  }),
17
- typescript({ noEmitOnError: true }),
18
25
  copy({
19
26
  targets: [
20
- { src: 'src/generators/add-entries/schema.json', dest: 'lib/generators/add-entries' },
21
- { src: 'src/generators/add-entries/files/*', dest: 'lib/generators/add-entries/files' },
22
- { src: 'src/generators/add-entries/entries/*', dest: 'lib/generators/add-entries/entries' },
27
+ { src: 'src/generators/add-frontend/schema.json', dest: 'lib/generators/add-frontend' },
28
+ { src: 'src/generators/add-frontend/templates/*', dest: 'lib/generators/add-frontend/templates' },
29
+ { src: 'src/generators/add-frontend/frameworks/*', dest: 'lib/generators/add-frontend/frameworks' },
23
30
  ],
24
31
  verbose: true,
25
32
  }),
@@ -1,19 +1,19 @@
1
1
  import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
2
2
  import { Tree, readProjectConfiguration } from '@nx/devkit';
3
3
 
4
- import { addEntriesGenerator } from './generator';
5
- import { AddEntriesGeneratorSchema } from './schema';
4
+ import { addFrontendGenerator } from './generator';
5
+ import { AddFrontendGeneratorSchema } from './schema';
6
6
 
7
- describe('add-entries generator', () => {
7
+ describe('add-frontend generator', () => {
8
8
  let tree: Tree;
9
- const options: AddEntriesGeneratorSchema = { projectPath: '/' };
9
+ const options: AddFrontendGeneratorSchema = { ns: 'test' };
10
10
 
11
11
  beforeEach(() => {
12
12
  tree = createTreeWithEmptyWorkspace();
13
13
  });
14
14
 
15
15
  it('should run successfully', async () => {
16
- await addEntriesGenerator(tree, options);
16
+ await addFrontendGenerator(tree, options);
17
17
  const config = readProjectConfiguration(tree, 'test');
18
18
  expect(config).toBeDefined();
19
19
  });
@@ -0,0 +1,50 @@
1
+ import { addProjectConfiguration, formatFiles, generateFiles, Tree, updateJson } from '@nx/devkit';
2
+ import * as path from 'path';
3
+ import { AddFrontendGeneratorSchema } from './schema';
4
+ import * as fs from 'node:fs';
5
+
6
+ const DEFAULT_FRAMEWORK = 'antui';
7
+
8
+ const resetProject = (rootDir: string) => {
9
+ if (fs.existsSync(`${rootDir}/project.json`)) {
10
+ fs.unlinkSync(`${rootDir}/project.json`);
11
+ }
12
+ if (fs.existsSync(`${rootDir}/src`)) {
13
+ fs.rmSync(`${rootDir}/src`, { recursive: true, force: true });
14
+ }
15
+ }
16
+
17
+ export async function addFrontendGenerator(tree: Tree, options: AddFrontendGeneratorSchema) {
18
+ const basePath = process.cwd();
19
+ const projectName = `frontend-${options.ns}-server`;
20
+ const projectRoot = options.path ? `${options.path}${projectName}` : projectName;
21
+ const projectSrc = `${projectRoot}/src`;
22
+ // const sourcePath = path.join(__dirname, 'entries');
23
+
24
+ const framework = options.framework || DEFAULT_FRAMEWORK;
25
+ console.log('UI framework specified: ', framework);
26
+
27
+ resetProject(`${basePath}/${projectRoot}`);
28
+
29
+ // addProjectConfiguration(tree, framework, {
30
+ // root: projectRoot,
31
+ // projectType: 'library',
32
+ // sourceRoot: projectSrc,
33
+ // targets: {},
34
+ // });
35
+
36
+ generateFiles(tree, path.join(__dirname, 'templates'), projectRoot, {});
37
+ generateFiles(tree, path.join(__dirname, 'frameworks', framework), projectSrc, options);
38
+ updateJson(tree, `${projectRoot}/package.json`, (packageJson) => {
39
+ packageJson['name'] = projectName;
40
+ return packageJson;
41
+ });
42
+ updateJson(tree, `${projectRoot}/config.json`, (configJson) => {
43
+ configJson['uiFramework'] = framework;
44
+ return configJson;
45
+ });
46
+
47
+ await formatFiles(tree);
48
+ }
49
+
50
+ export default addFrontendGenerator;
@@ -0,0 +1,5 @@
1
+ export interface AddFrontendGeneratorSchema {
2
+ ns: string;
3
+ path?: string;
4
+ framework?: string;
5
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "$schema": "https://json-schema.org/schema",
3
+ "$id": "AddFrontend",
4
+ "title": "",
5
+ "type": "object",
6
+ "properties": {
7
+ "ns": {
8
+ "type": "string",
9
+ "description": "The project namespace"
10
+ },
11
+ "path": {
12
+ "type": "string",
13
+ "description": "The project path ex: \"servers/\", default: \"/\""
14
+ },
15
+ "framework": {
16
+ "type": "string",
17
+ "description": "UI framework in [antui, chakraui]"
18
+ }
19
+ },
20
+ "required": ["ns"]
21
+ }
package/src/index.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from './generators/add-entries/generator';
2
- // export const schema = import('./generators/add-entries/schema.json');
1
+ export * from './generators/add-frontend/generator';
2
+ // export const schema = import('./generators/add-frontend/schema.json');
@@ -1,55 +0,0 @@
1
- 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var tslib=require('tslib'),devkit=require('@nx/devkit'),path=require('path'),fs=require('node:fs');function _interopNamespaceDefault(e){var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var path__namespace=/*#__PURE__*/_interopNamespaceDefault(path);var fs__namespace=/*#__PURE__*/_interopNamespaceDefault(fs);const loadJSON = (path) => {
2
- const content = fs__namespace.readFileSync(path);
3
- return JSON.parse(content);
4
- };
5
- const getFramework = (projectRoot) => tslib.__awaiter(void 0, void 0, void 0, function* () {
6
- // const mergeConfigPath = path.join(projectRoot, 'tools', 'mergeConfig.js');
7
- // const webConfigPath = path.join(projectRoot, 'app', 'cde-webconfig.json');
8
- const configPath = `${projectRoot}/config.json`;
9
- try {
10
- const json = loadJSON(configPath);
11
- return json === null || json === void 0 ? void 0 : json.uiFramework;
12
- }
13
- catch (err) {
14
- console.warn('Error while getting UI framework', err.message);
15
- return null;
16
- }
17
- });
18
- const resetProject = (rootDir) => {
19
- if (fs__namespace.existsSync(`${rootDir}/project.json`)) {
20
- fs__namespace.unlinkSync(`${rootDir}/project.json`);
21
- }
22
- if (fs__namespace.existsSync(`${rootDir}/src`)) {
23
- fs__namespace.rmSync(`${rootDir}/src`, { recursive: true, force: true });
24
- }
25
- };
26
- function addEntriesGenerator(tree, options) {
27
- return tslib.__awaiter(this, void 0, void 0, function* () {
28
- const basePath = process.cwd();
29
- const projectRoot = `${basePath}/${options.projectPath}`;
30
- const projectSrc = `${options.projectPath}/src`;
31
- // const sourcePath = path.join(__dirname, 'entries');
32
- try {
33
- let framework = yield getFramework(projectRoot);
34
- if (!framework) {
35
- framework = 'antui';
36
- }
37
- console.log('UI framework specified: ', framework);
38
- resetProject(projectRoot);
39
- // addProjectConfiguration(tree, framework, {
40
- // root: projectRoot,
41
- // projectType: 'library',
42
- // sourceRoot: projectSrc,
43
- // targets: {},
44
- // });
45
- devkit.generateFiles(tree, path__namespace.join(__dirname, 'files'), projectSrc, {});
46
- devkit.generateFiles(tree, path__namespace.join(__dirname, 'entries', framework), projectSrc, options);
47
- // await fs.cpSync(path.join(__dirname, 'files'), projectSrc, {recursive: true});
48
- // await fs.cpSync(path.join(__dirname, 'entries', framework), projectSrc, {recursive: true});
49
- yield devkit.formatFiles(tree);
50
- }
51
- catch (err) {
52
- console.error('Error while generating entries: ', err);
53
- }
54
- });
55
- }exports.addEntriesGenerator=addEntriesGenerator;exports.default=addEntriesGenerator;//# sourceMappingURL=generator.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generator.cjs","sources":["../../../src/generators/add-entries/generator.ts"],"sourcesContent":[null],"names":["fs","__awaiter","generateFiles","path","formatFiles"],"mappings":"mkBAKA,MAAM,QAAQ,GAAG,CAAC,IAAI,KAAI;IACtB,MAAM,OAAO,GAAGA,aAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;AACtC,IAAA,OAAO,IAAI,CAAC,KAAK,CAAC,OAAc,CAAC,CAAC;AACtC,CAAC,CAAA;AAED,MAAM,YAAY,GAAG,CAAO,WAAW,KAAIC,eAAA,CAAA,KAAA,CAAA,EAAA,KAAA,CAAA,EAAA,KAAA,CAAA,EAAA,aAAA;;;AAGvC,IAAA,MAAM,UAAU,GAAG,CAAG,EAAA,WAAW,cAAc,CAAC;AAEhD,IAAA,IAAI;AACA,QAAA,MAAM,IAAI,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC;AAClC,QAAA,OAAO,IAAI,KAAJ,IAAA,IAAA,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC;KAC5B;IAAC,OAAM,GAAG,EAAE;QACT,OAAO,CAAC,IAAI,CAAC,kCAAkC,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;AAC9D,QAAA,OAAO,IAAI,CAAC;KACf;AACL,CAAC,CAAA,CAAA;AAED,MAAM,YAAY,GAAG,CAAC,OAAe,KAAI;IACrC,IAAID,aAAE,CAAC,UAAU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;QAAC,OAAO,GAAG,EAAE;AACV,YAAA,OAAO,CAAC,KAAK,CAAC,kCAAkC,EAAE,GAAG,CAAC,CAAC;SAC1D;KACJ,CAAA,CAAA;AAAA"}
@@ -1,4 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- import { AddEntriesGeneratorSchema } from './schema';
3
- export declare function addEntriesGenerator(tree: Tree, options: AddEntriesGeneratorSchema): Promise<void>;
4
- export default addEntriesGenerator;
@@ -1,55 +0,0 @@
1
- import {__awaiter}from'tslib';import {generateFiles,formatFiles}from'@nx/devkit';import*as path from'path';import*as fs from'node:fs';const loadJSON = (path) => {
2
- const content = fs.readFileSync(path);
3
- return JSON.parse(content);
4
- };
5
- const getFramework = (projectRoot) => __awaiter(void 0, void 0, void 0, function* () {
6
- // const mergeConfigPath = path.join(projectRoot, 'tools', 'mergeConfig.js');
7
- // const webConfigPath = path.join(projectRoot, 'app', 'cde-webconfig.json');
8
- const configPath = `${projectRoot}/config.json`;
9
- try {
10
- const json = loadJSON(configPath);
11
- return json === null || json === void 0 ? void 0 : json.uiFramework;
12
- }
13
- catch (err) {
14
- console.warn('Error while getting UI framework', err.message);
15
- return null;
16
- }
17
- });
18
- const resetProject = (rootDir) => {
19
- if (fs.existsSync(`${rootDir}/project.json`)) {
20
- fs.unlinkSync(`${rootDir}/project.json`);
21
- }
22
- if (fs.existsSync(`${rootDir}/src`)) {
23
- fs.rmSync(`${rootDir}/src`, { recursive: true, force: true });
24
- }
25
- };
26
- function addEntriesGenerator(tree, options) {
27
- return __awaiter(this, void 0, void 0, function* () {
28
- const basePath = process.cwd();
29
- const projectRoot = `${basePath}/${options.projectPath}`;
30
- const projectSrc = `${options.projectPath}/src`;
31
- // const sourcePath = path.join(__dirname, 'entries');
32
- try {
33
- let framework = yield getFramework(projectRoot);
34
- if (!framework) {
35
- framework = 'antui';
36
- }
37
- console.log('UI framework specified: ', framework);
38
- resetProject(projectRoot);
39
- // addProjectConfiguration(tree, framework, {
40
- // root: projectRoot,
41
- // projectType: 'library',
42
- // sourceRoot: projectSrc,
43
- // targets: {},
44
- // });
45
- generateFiles(tree, path.join(__dirname, 'files'), projectSrc, {});
46
- generateFiles(tree, path.join(__dirname, 'entries', framework), projectSrc, options);
47
- // await fs.cpSync(path.join(__dirname, 'files'), projectSrc, {recursive: true});
48
- // await fs.cpSync(path.join(__dirname, 'entries', framework), projectSrc, {recursive: true});
49
- yield formatFiles(tree);
50
- }
51
- catch (err) {
52
- console.error('Error while generating entries: ', err);
53
- }
54
- });
55
- }export{addEntriesGenerator,addEntriesGenerator as default};//# sourceMappingURL=generator.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generator.mjs","sources":["../../../src/generators/add-entries/generator.ts"],"sourcesContent":[null],"names":[],"mappings":"sIAKA,MAAM,QAAQ,GAAG,CAAC,IAAI,KAAI;IACtB,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;AACtC,IAAA,OAAO,IAAI,CAAC,KAAK,CAAC,OAAc,CAAC,CAAC;AACtC,CAAC,CAAA;AAED,MAAM,YAAY,GAAG,CAAO,WAAW,KAAI,SAAA,CAAA,KAAA,CAAA,EAAA,KAAA,CAAA,EAAA,KAAA,CAAA,EAAA,aAAA;;;AAGvC,IAAA,MAAM,UAAU,GAAG,CAAG,EAAA,WAAW,cAAc,CAAC;AAEhD,IAAA,IAAI;AACA,QAAA,MAAM,IAAI,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC;AAClC,QAAA,OAAO,IAAI,KAAJ,IAAA,IAAA,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAC;KAC5B;IAAC,OAAM,GAAG,EAAE;QACT,OAAO,CAAC,IAAI,CAAC,kCAAkC,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;AAC9D,QAAA,OAAO,IAAI,CAAC;KACf;AACL,CAAC,CAAA,CAAA;AAED,MAAM,YAAY,GAAG,CAAC,OAAe,KAAI;IACrC,IAAI,EAAE,CAAC,UAA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,GAAG,EAAE;AACV,YAAA,OAAO,CAAC,KAAK,CAAC,kCAAkC,EAAE,GAAG,CAAC,CAAC;SAC1D;KACJ,CAAA,CAAA;AAAA"}
@@ -1,13 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/schema",
3
- "$id": "AddEntries",
4
- "title": "",
5
- "type": "object",
6
- "properties": {
7
- "projectPath": {
8
- "type": "string",
9
- "description": "The project relative path (ex: servers/frontend-server)"
10
- }
11
- },
12
- "required": ["projectPath"]
13
- }
@@ -1,8 +0,0 @@
1
- import * as React from 'react';
2
- import { createCache as createAntdCache, extractStyle, StyleProvider } from '@ant-design/cssinjs';
3
-
4
- const antdCache = createAntdCache();
5
- export const styleSheet = extractStyle(antdCache);
6
- export const AntSytles = ({ children }: { children: React.ReactNode }) => (
7
- <StyleProvider cache={antdCache}>{children}</StyleProvider>
8
- );
@@ -1,7 +0,0 @@
1
- import createCache from '@emotion/cache';
2
-
3
- export const defaultCache = createEmotionCache();
4
-
5
- export default function createEmotionCache() {
6
- return createCache({ key: 'css', prepend: true });
7
- }
@@ -1,3 +0,0 @@
1
- export * from './AntStyles';
2
- export * from './createEmotionCache';
3
- export * from './utils';
@@ -1,16 +0,0 @@
1
- import { isEmpty } from 'lodash-es';
2
-
3
- export function jsonToString(json) {
4
- if (isEmpty(json)) {
5
- return '';
6
- }
7
-
8
- if (Array.isArray(json)) {
9
- let arr = json.map((a) => jsonToString(a));
10
- return arr.join(' ');
11
- }
12
-
13
- const str = JSON.stringify(json);
14
- const arr = str.split(',');
15
- return Array.isArray(arr) ? arr.join(' ') : str;
16
- }
@@ -1,66 +0,0 @@
1
- import { addProjectConfiguration, formatFiles, generateFiles, Tree } from '@nx/devkit';
2
- import * as path from 'path';
3
- import { AddEntriesGeneratorSchema } from './schema';
4
- import * as fs from 'node:fs';
5
-
6
- const loadJSON = (path) => {
7
- const content = fs.readFileSync(path);
8
- return JSON.parse(content as any);
9
- }
10
-
11
- const getFramework = async (projectRoot) => {
12
- // const mergeConfigPath = path.join(projectRoot, 'tools', 'mergeConfig.js');
13
- // const webConfigPath = path.join(projectRoot, 'app', 'cde-webconfig.json');
14
- const configPath = `${projectRoot}/config.json`;
15
-
16
- try {
17
- const json = loadJSON(configPath);
18
- return json?.uiFramework;
19
- } catch(err) {
20
- console.warn('Error while getting UI framework', err.message);
21
- return null;
22
- }
23
- }
24
-
25
- const resetProject = (rootDir: string) => {
26
- if (fs.existsSync(`${rootDir}/project.json`)) {
27
- fs.unlinkSync(`${rootDir}/project.json`);
28
- }
29
- if (fs.existsSync(`${rootDir}/src`)) {
30
- fs.rmSync(`${rootDir}/src`, { recursive: true, force: true });
31
- }
32
- }
33
-
34
- export async function addEntriesGenerator(tree: Tree, options: AddEntriesGeneratorSchema) {
35
- const basePath = process.cwd();
36
- const projectRoot = `${basePath}/${options.projectPath}`;
37
- const projectSrc = `${options.projectPath}/src`;
38
- // const sourcePath = path.join(__dirname, 'entries');
39
- try {
40
- let framework = await getFramework(projectRoot);
41
- if (!framework) {
42
- framework = 'antui';
43
- }
44
- console.log('UI framework specified: ', framework);
45
-
46
- resetProject(projectRoot);
47
-
48
- // addProjectConfiguration(tree, framework, {
49
- // root: projectRoot,
50
- // projectType: 'library',
51
- // sourceRoot: projectSrc,
52
- // targets: {},
53
- // });
54
-
55
- generateFiles(tree, path.join(__dirname, 'files'), projectSrc, {});
56
- generateFiles(tree, path.join(__dirname, 'entries', framework), projectSrc, options);
57
- // await fs.cpSync(path.join(__dirname, 'files'), projectSrc, {recursive: true});
58
- // await fs.cpSync(path.join(__dirname, 'entries', framework), projectSrc, {recursive: true});
59
- await formatFiles(tree);
60
-
61
- } catch (err) {
62
- console.error('Error while generating entries: ', err);
63
- }
64
- }
65
-
66
- export default addEntriesGenerator;
@@ -1,3 +0,0 @@
1
- export interface AddEntriesGeneratorSchema {
2
- projectPath: string;
3
- }
@@ -1,13 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/schema",
3
- "$id": "AddEntries",
4
- "title": "",
5
- "type": "object",
6
- "properties": {
7
- "projectPath": {
8
- "type": "string",
9
- "description": "The project relative path (ex: servers/frontend-server)"
10
- }
11
- },
12
- "required": ["projectPath"]
13
- }