@common-stack/generate-plugin 8.0.1-alpha.0 → 8.0.1-alpha.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.
- package/CHANGELOG.md +8 -0
- package/lib/common/package-releases/package.json +26 -0
- package/lib/common/package-releases/package.json.cjs +33 -0
- package/lib/common/package-releases/package.json.cjs.map +1 -0
- package/lib/common/package-releases/package.json.mjs +33 -0
- package/lib/common/package-releases/package.json.mjs.map +1 -0
- package/lib/generators/add-backend/files/package.json +2 -2
- package/{src/generators/add-frontend/frameworks/antui → lib/generators/add-frontend/frameworks/antui/src}/entry.client.tsx.template +0 -3
- package/{src/generators/add-frontend/frameworks/antui → lib/generators/add-frontend/frameworks/antui/src}/entry.server.tsx.template +1 -0
- package/lib/generators/add-frontend/frameworks/antui/{root.tsx.template → src/root.tsx.template} +1 -11
- package/lib/generators/add-frontend/frameworks/tailwindui/postcss.config.js +6 -0
- package/lib/generators/add-frontend/generator.cjs +83 -36
- package/lib/generators/add-frontend/generator.cjs.map +1 -1
- package/lib/generators/add-frontend/generator.mjs +83 -36
- package/lib/generators/add-frontend/generator.mjs.map +1 -1
- package/lib/generators/add-frontend/templates/package.json +4 -4
- package/lib/generators/add-fullstack/files/cdecode-config.json +17 -0
- package/lib/generators/add-fullstack/files/package.json +10 -10
- package/lib/generators/add-fullstack/generator.cjs +8 -4
- package/lib/generators/add-fullstack/generator.cjs.map +1 -1
- package/lib/generators/add-fullstack/generator.mjs +8 -4
- package/lib/generators/add-fullstack/generator.mjs.map +1 -1
- package/lib/generators/add-fullstack/schema.json +1 -1
- package/lib/generators/add-moleculer/files/package.json +5 -5
- package/package.json +4 -3
- package/rollup.config.mjs +3 -0
- package/src/common/package-releases/package.json +26 -0
- package/src/generators/add-frontend/__snapshots__/generator.test.ts.snap +33 -0
- package/{lib/generators/add-frontend/frameworks/antui → src/generators/add-frontend/frameworks/antui/src}/entry.client.tsx.template +0 -3
- package/{lib/generators/add-frontend/frameworks/antui → src/generators/add-frontend/frameworks/antui/src}/entry.server.tsx.template +1 -0
- package/src/generators/add-frontend/frameworks/antui/{root.tsx.template → src/root.tsx.template} +1 -11
- package/src/generators/add-frontend/frameworks/tailwindui/postcss.config.js +6 -0
- package/src/generators/add-frontend/frameworks/tailwindui/tailwind.config.ts.template +12 -0
- package/src/generators/add-frontend/generator.test.ts +79 -0
- package/src/generators/add-frontend/generator.ts +109 -44
- package/src/generators/add-fullstack/files/cdecode-config.json +17 -0
- package/src/generators/add-fullstack/files/package.json +10 -10
- package/src/generators/add-fullstack/generator.ts +10 -11
- package/src/generators/add-fullstack/schema.json +1 -1
- package/src/generators/add-moleculer/files/package.json +5 -5
- package/tsconfig.spec.json +9 -0
- package/docker-releases/backend/package.json +0 -134
- package/docker-releases/frontend/antd/package.json +0 -121
- package/lib/generators/add-frontend/templates/postcss.config.js +0 -6
- package/src/generators/add-frontend/generator.spec.ts +0 -20
- /package/lib/generators/add-frontend/frameworks/antui/{context.tsx.template → src/context.tsx.template} +0 -0
- /package/lib/generators/add-frontend/frameworks/chakraui/{context.tsx.template → src/context.tsx.template} +0 -0
- /package/lib/generators/add-frontend/frameworks/chakraui/{entry.client.tsx.template → src/entry.client.tsx.template} +0 -0
- /package/lib/generators/add-frontend/frameworks/chakraui/{entry.server.tsx.template → src/entry.server.tsx.template} +0 -0
- /package/lib/generators/add-frontend/frameworks/chakraui/{root.tsx.template → src/root.tsx.template} +0 -0
- /package/lib/generators/add-frontend/frameworks/tailwindui/{entry.client.tsx.template → src/entry.client.tsx.template} +0 -0
- /package/lib/generators/add-frontend/frameworks/tailwindui/{entry.server.tsx.template → src/entry.server.tsx.template} +0 -0
- /package/lib/generators/add-frontend/frameworks/tailwindui/{root.tsx.template → src/root.tsx.template} +0 -0
- /package/lib/generators/add-frontend/frameworks/tailwindui/{tailwind.css → src/tailwind.css} +0 -0
- /package/lib/generators/add-frontend/{templates → frameworks/tailwindui}/tailwind.config.ts.template +0 -0
- /package/lib/generators/add-frontend/{generator.spec.d.ts → generator.test.d.ts} +0 -0
- /package/src/generators/add-frontend/frameworks/antui/{context.tsx.template → src/context.tsx.template} +0 -0
- /package/src/generators/add-frontend/frameworks/chakraui/{context.tsx.template → src/context.tsx.template} +0 -0
- /package/src/generators/add-frontend/frameworks/chakraui/{entry.client.tsx.template → src/entry.client.tsx.template} +0 -0
- /package/src/generators/add-frontend/frameworks/chakraui/{entry.server.tsx.template → src/entry.server.tsx.template} +0 -0
- /package/src/generators/add-frontend/frameworks/chakraui/{root.tsx.template → src/root.tsx.template} +0 -0
- /package/src/generators/add-frontend/frameworks/tailwindui/{entry.client.tsx.template → src/entry.client.tsx.template} +0 -0
- /package/src/generators/add-frontend/frameworks/tailwindui/{entry.server.tsx.template → src/entry.server.tsx.template} +0 -0
- /package/src/generators/add-frontend/frameworks/tailwindui/{root.tsx.template → src/root.tsx.template} +0 -0
- /package/src/generators/add-frontend/frameworks/tailwindui/{tailwind.css → src/tailwind.css} +0 -0
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var tslib=require('tslib'),devkit=require('@nx/devkit'),path=require('path'),fs=require('fs'),index=require('../../utils/index.cjs'),jenkinsfileUpdate=require('./updates/jenkinsfileUpdate.cjs'),packageJsonUpdate=require('./updates/packageJsonUpdate.cjs'),lernaJsonUpdate=require('./updates/lernaJsonUpdate.cjs'),htmlPluginUpdate=require('./updates/htmlPluginUpdate.cjs'),licenseUpdate=require('./updates/licenseUpdate.cjs'),ignoreUpdate=require('./updates/ignoreUpdate.cjs'),generator$2=require('../add-frontend/generator.cjs'),generator$1=require('../add-backend/generator.cjs'),generator=require('../add-moleculer/generator.cjs'),generator$3=require('../add-package/generator.cjs');require('../../executors/update-deploy-version/executor.cjs');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);function addFullstackGenerator(tree, options) {
|
|
2
2
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
3
3
|
var _a;
|
|
4
|
-
|
|
4
|
+
let projectPath = options.path || '';
|
|
5
|
+
if (projectPath !== '') {
|
|
6
|
+
const basePath = process.cwd();
|
|
7
|
+
projectPath = path__namespace.relative(basePath, projectPath);
|
|
8
|
+
}
|
|
5
9
|
const projectName = (_a = index.getValid(options.name)) !== null && _a !== void 0 ? _a : 'fullstack-pro';
|
|
6
|
-
const projectRoot = path__namespace.join(
|
|
7
|
-
console.log(`
|
|
10
|
+
const projectRoot = path__namespace.join(projectPath, projectName);
|
|
11
|
+
// console.log(`Project Path: ${projectPath}`);
|
|
8
12
|
// backup existing lerna values
|
|
9
13
|
const lernaBackup = lernaJsonUpdate.backupLernaJson(tree, projectRoot);
|
|
10
14
|
// backup files codegen.yaml
|
|
@@ -25,7 +29,7 @@
|
|
|
25
29
|
ignoreUpdate.restoreFiles(tree, projectRoot, filesBackup);
|
|
26
30
|
yield devkit.formatFiles(tree);
|
|
27
31
|
if (index.isValid(options.config)) {
|
|
28
|
-
const configPath = path__namespace.resolve(
|
|
32
|
+
const configPath = path__namespace.resolve(projectPath, index.getValid(options.config));
|
|
29
33
|
if (fs__namespace.existsSync(configPath)) {
|
|
30
34
|
try {
|
|
31
35
|
const configs = JSON.parse(fs__namespace.readFileSync(configPath).toString());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.cjs","sources":["../../../src/generators/add-fullstack/generator.ts"],"sourcesContent":[null],"names":["
|
|
1
|
+
{"version":3,"file":"generator.cjs","sources":["../../../src/generators/add-fullstack/generator.ts"],"sourcesContent":[null],"names":["path","getValid","backupLernaJson","backupFiles","generateFiles","updateJenkinsFile","updatePackageJson","updateHtmlPlugin","restoreLernaJson","restoreFiles","formatFiles","isValid","fs","updateLicense","__awaiter","generateFrontend","generateBackend","generateMoleculer","generatePackage","updateRepository"],"mappings":"0sCAoBsB,SAAA,qBAAqB,CAAC,IAAU,EAAE,OAAoC,EAAA;;;AACxF,QAAA,IAAI,WAAW,GAAG,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC;AACrC,QAAA,IAAI,WAAW,KAAK,EAAE,EAAE;AACpB,YAAA,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;YAC/B,WAAW,GAAGA,eAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;SACtD;QACD,MAAM,WAAW,GAAG,CAAA,EAAA,GAAAC,cAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,MAAI,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAA,eAAe,CAAC;QAC9D,MAAM,WAAW,GAAGD,eAAI,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;;;QAKxD,MAAM,WAAW,GAAGE,+BAAe,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;;QAGvD,MAAM,aAAa,GAAG,CAAC,aAAa,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,mBAAmB,CAAC,CAAC;QAClG,MAAM,WAAW,GAAGC,wBAAW,CAAC,IAAI,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC;AAElE,QAAAC,oBAAa,CAAC,IAAI,EAAEJ,eAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;;AAGzE,QAAAK,mCAAiB,CAAC,IAAI,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;;QAGlDC,mCAAiB,CAAC,IAAI,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC;;AAG5D,QAAAC,iCAAgB,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC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AC,EAChD,EAAE,EAAE,OAAO,CAAC,EAAE,EACd,IAAI,EAAE,WAAW,GACpB,CAAC;YACF,MAAMkB,2BAAe,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;SAC/C;KACJ;AACL,CAAC,CAAA,CAAC;AAEF,MAAM,cAAc,GAAG,CAAO,IAAU,EAAE,OAAY,KAAIJ,eAAA,CAAA,KAAA,CAAA,EAAA,KAAA,CAAA,EAAA,KAAA,CAAA,EAAA,aAAA;AACtD,IAAA,IAAI,OAAO,CAAC,OAAO,EAAE;AACjB,QAAA,MAAM,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;KACxC;IAED,IAAI,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAC,OAAO,EAAE;AAC9C,QAAA,MAAM,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;KACxC;AAED,IAAA,IAAI,OAAO,CAAC,OAAO,EAAE;AACjB,QAAAR,mCAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,EAAE,EAAE,OAAO,EAAEL,cAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;KACnF;AAED,IAAA,IAAI,OAAO,CAAC,UAAU,EAAE;QACpBkB,kCAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;KAC9D;AACL,CAAC,CAAA"}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import {__awaiter}from'tslib';import {generateFiles,formatFiles}from'@nx/devkit';import*as path from'path';import*as fs from'fs';import {getValid,isValid}from'../../utils/index.mjs';import {updateJenkinsFile}from'./updates/jenkinsfileUpdate.mjs';import {updatePackageJson,updateRepository}from'./updates/packageJsonUpdate.mjs';import {backupLernaJson,restoreLernaJson}from'./updates/lernaJsonUpdate.mjs';import {updateHtmlPlugin}from'./updates/htmlPluginUpdate.mjs';import {updateLicense}from'./updates/licenseUpdate.mjs';import {backupFiles,restoreFiles}from'./updates/ignoreUpdate.mjs';import {generateFrontend}from'../add-frontend/generator.mjs';import {generateBackend}from'../add-backend/generator.mjs';import {generateMoleculer}from'../add-moleculer/generator.mjs';import {generatePackage}from'../add-package/generator.mjs';import'../../executors/update-deploy-version/executor.mjs';function addFullstackGenerator(tree, options) {
|
|
2
2
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3
3
|
var _a;
|
|
4
|
-
|
|
4
|
+
let projectPath = options.path || '';
|
|
5
|
+
if (projectPath !== '') {
|
|
6
|
+
const basePath = process.cwd();
|
|
7
|
+
projectPath = path.relative(basePath, projectPath);
|
|
8
|
+
}
|
|
5
9
|
const projectName = (_a = getValid(options.name)) !== null && _a !== void 0 ? _a : 'fullstack-pro';
|
|
6
|
-
const projectRoot = path.join(
|
|
7
|
-
console.log(`
|
|
10
|
+
const projectRoot = path.join(projectPath, projectName);
|
|
11
|
+
// console.log(`Project Path: ${projectPath}`);
|
|
8
12
|
// backup existing lerna values
|
|
9
13
|
const lernaBackup = backupLernaJson(tree, projectRoot);
|
|
10
14
|
// backup files codegen.yaml
|
|
@@ -25,7 +29,7 @@ import {__awaiter}from'tslib';import {generateFiles,formatFiles}from'@nx/devkit'
|
|
|
25
29
|
restoreFiles(tree, projectRoot, filesBackup);
|
|
26
30
|
yield formatFiles(tree);
|
|
27
31
|
if (isValid(options.config)) {
|
|
28
|
-
const configPath = path.resolve(
|
|
32
|
+
const configPath = path.resolve(projectPath, getValid(options.config));
|
|
29
33
|
if (fs.existsSync(configPath)) {
|
|
30
34
|
try {
|
|
31
35
|
const configs = JSON.parse(fs.readFileSync(configPath).toString());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.mjs","sources":["../../../src/generators/add-fullstack/generator.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generator.mjs","sources":["../../../src/generators/add-fullstack/generator.ts"],"sourcesContent":[null],"names":[],"mappings":"y3BAoB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C/C;KACJ;AACL,CAAC,CAAA,CAAC;AAEF,MAAM,cAAc,GAAG,CAAO,IAAU,EAAE,OAAY,KAAI,SAAA,CAAA,KAAA,CAAA,EAAA,KAAA,CAAA,EAAA,KAAA,CAAA,EAAA,aAAA;AACtD,IAAA,IAAI,OAAO,CAAC,OAAO,EAAE;AACjB,QAAA,MAAM,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;KACxC;IAED,IAAI,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAC,OAAO,EAAE;AAC9C,QAAA,MAAM,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;KACxC;AAED,IAAA,IAAI,OAAO,CAAC,OAAO,EAAE;AACjB,QAAA,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;KACnF;AAED,IAAA,IAAI,OAAO,CAAC,UAAU,EAAE;QACpB,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;KAC9D;AACL,CAAC,CAAA"}
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"path": {
|
|
17
17
|
"type": "string",
|
|
18
18
|
"description": "The base path where the project will be created or updated",
|
|
19
|
-
"x-prompt": "Where do you want to create or update the project? (
|
|
19
|
+
"x-prompt": "Where do you want to create or update the project? (Please provide in absolute path, or leave empty for the current directory)"
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"required": ["name"]
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
"common": "link:./common"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@common-stack/client-core": "
|
|
33
|
-
"@common-stack/core": "
|
|
34
|
-
"@common-stack/server-core": "
|
|
35
|
-
"@common-stack/server-stack": "
|
|
36
|
-
"@common-stack/store-mongo": "
|
|
32
|
+
"@common-stack/client-core": "8.0.1-alpha.0",
|
|
33
|
+
"@common-stack/core": "8.0.1-alpha.0",
|
|
34
|
+
"@common-stack/server-core": "8.0.1-alpha.0",
|
|
35
|
+
"@common-stack/server-stack": "8.0.1-alpha.0",
|
|
36
|
+
"@common-stack/store-mongo": "8.0.1-alpha.0",
|
|
37
37
|
"@container-stack/mailing-api": "5.2.1-alpha.1",
|
|
38
38
|
"helmet": "^3.21.2",
|
|
39
39
|
"react": "18.2.0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@common-stack/generate-plugin",
|
|
3
|
-
"version": "8.0.1-alpha.
|
|
3
|
+
"version": "8.0.1-alpha.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./lib/index.mjs",
|
|
6
6
|
"typings": "./lib/index.d.ts",
|
|
@@ -14,10 +14,11 @@
|
|
|
14
14
|
"test": "cross-env ENV_FILE=../../config/test/test.env jest",
|
|
15
15
|
"test:debug": "npm test -- --runInBand",
|
|
16
16
|
"test:watch": "npm test -- --watch",
|
|
17
|
+
"vitest": "cross-env ENV_FILE=../../config/test/test.env vitest",
|
|
17
18
|
"watch": "yarn build:lib:watch"
|
|
18
19
|
},
|
|
19
20
|
"dependencies": {
|
|
20
|
-
"@common-stack/rollup-vite-utils": "8.0.1-alpha.
|
|
21
|
+
"@common-stack/rollup-vite-utils": "8.0.1-alpha.2",
|
|
21
22
|
"tslib": "^2.3.0"
|
|
22
23
|
},
|
|
23
24
|
"publishConfig": {
|
|
@@ -25,5 +26,5 @@
|
|
|
25
26
|
},
|
|
26
27
|
"executors": "./executors.json",
|
|
27
28
|
"generators": "./generators.json",
|
|
28
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "740324071e77326fc0d9dd3ce4a1bc4a64a472f8"
|
|
29
30
|
}
|
package/rollup.config.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import image from '@rollup/plugin-image';
|
|
|
3
3
|
import typescript from '@rollup/plugin-typescript';
|
|
4
4
|
import { string } from 'rollup-plugin-string';
|
|
5
5
|
import copy from 'rollup-plugin-copy';
|
|
6
|
+
import json from '@rollup/plugin-json';
|
|
6
7
|
|
|
7
8
|
// Define a base configuration for reuse
|
|
8
9
|
const baseConfig = {
|
|
@@ -18,6 +19,7 @@ const baseConfig = {
|
|
|
18
19
|
include: '**/*.graphql',
|
|
19
20
|
exclude: ['src/generators'],
|
|
20
21
|
}),
|
|
22
|
+
json(),
|
|
21
23
|
typescript({
|
|
22
24
|
noEmitOnError: true,
|
|
23
25
|
exclude: ['src/generators'],
|
|
@@ -37,6 +39,7 @@ const baseConfig = {
|
|
|
37
39
|
{ src: 'src/generators/add-package/files/*', dest: 'lib/generators/add-package/files' },
|
|
38
40
|
{ src: 'src/executors/update-deploy-version/schema.json', dest: 'lib/executors/update-deploy-version' },
|
|
39
41
|
{ src: 'src/executors/sort-package-json/schema.json', dest: 'lib/executors/sort-package-json' },
|
|
42
|
+
{ src: 'src/common/package-releases/package.json', dest: 'lib/common/package-releases' },
|
|
40
43
|
],
|
|
41
44
|
verbose: false,
|
|
42
45
|
}),
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "sample-stack-frontend-server",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"resolutions": {
|
|
6
|
+
"common": "link:./common"
|
|
7
|
+
},
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"@admin-layout/ant-design-pro": "10.0.2-alpha.4",
|
|
10
|
+
"@ant-design/static-style-extract": "^1.0.3",
|
|
11
|
+
"@chakra-ui/react": "^2.8.0",
|
|
12
|
+
"@emotion/css": "^11.13.5",
|
|
13
|
+
"@emotion/react": "^11.14.0",
|
|
14
|
+
"@emotion/server": "^11.11.0",
|
|
15
|
+
"@emotion/styled": "^11.14.0",
|
|
16
|
+
"antd": "^5.23.4",
|
|
17
|
+
"autoprefixer": "^10.4.20",
|
|
18
|
+
"framer-motion": "^12.4.1",
|
|
19
|
+
"postcss": "^8.5.1",
|
|
20
|
+
"tailwindcss": "^4.0.4"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"body-parser": "*"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`addFrontendGenerator should add missing dependencies and update config.json for antui 1`] = `
|
|
4
|
+
{
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@admin-layout/ant-design-pro": "10.0.2-alpha.4",
|
|
7
|
+
"@ant-design/static-style-extract": "^1.0.3",
|
|
8
|
+
"@emotion/css": "^11.13.5",
|
|
9
|
+
"@emotion/react": "^11.14.0",
|
|
10
|
+
"@emotion/server": "^11.11.0",
|
|
11
|
+
"@emotion/styled": "^11.14.0",
|
|
12
|
+
"antd": "^5.23.4",
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {},
|
|
15
|
+
"name": "frontend-demo-server",
|
|
16
|
+
}
|
|
17
|
+
`;
|
|
18
|
+
|
|
19
|
+
exports[`addFrontendGenerator should not override an already existing dependency version 1`] = `
|
|
20
|
+
{
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@admin-layout/ant-design-pro": "10.0.2-alpha.4",
|
|
23
|
+
"@ant-design/static-style-extract": "^1.0.3",
|
|
24
|
+
"@emotion/css": "^11.13.5",
|
|
25
|
+
"@emotion/react": "^11.14.0",
|
|
26
|
+
"@emotion/server": "^11.11.0",
|
|
27
|
+
"@emotion/styled": "^11.14.0",
|
|
28
|
+
"antd": "1.0.0",
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {},
|
|
31
|
+
"name": "frontend-demo-server",
|
|
32
|
+
}
|
|
33
|
+
`;
|
|
@@ -13,8 +13,6 @@ import { ApolloProvider } from '@apollo/client/index.js';
|
|
|
13
13
|
import { SlotFillProvider, removeUniversalPortals } from '@common-stack/components-pro';
|
|
14
14
|
import { InversifyProvider } from '@common-stack/client-react';
|
|
15
15
|
import { Provider as ReduxProvider } from 'react-redux';
|
|
16
|
-
// import { PersistGate } from 'redux-persist/integration/react';
|
|
17
|
-
// import { persistStore } from 'redux-persist';
|
|
18
16
|
import { CacheProvider } from '@emotion/react';
|
|
19
17
|
import i18next from 'i18next';
|
|
20
18
|
import { I18nextProvider, initReactI18next } from 'react-i18next';
|
|
@@ -36,7 +34,6 @@ import { LocaleContext } from './context';
|
|
|
36
34
|
|
|
37
35
|
const { apolloClient: client, container, serviceFunc } = createClientContainer();
|
|
38
36
|
const { store } = createReduxStore(client, serviceFunc(), container);
|
|
39
|
-
// const persistor = persistStore(store);
|
|
40
37
|
const antCache = createCache();
|
|
41
38
|
const cache = createEmotionCache();
|
|
42
39
|
|
|
@@ -27,6 +27,7 @@ import Backend from 'i18next-fs-backend';
|
|
|
27
27
|
import { resolve } from 'node:path';
|
|
28
28
|
// @ts-ignore
|
|
29
29
|
import { i18nextInstance as i18next } from '@app/frontend-stack-react/i18n-localization/i18next.server.js';
|
|
30
|
+
// @ts-ignore
|
|
30
31
|
import config from '@app/cde-webconfig.json';
|
|
31
32
|
// @ts-ignore
|
|
32
33
|
import createEmotionCache from '@app/frontend-stack-react/entries/common/createEmotionCache';
|
package/src/generators/add-frontend/frameworks/antui/{root.tsx.template → src/root.tsx.template}
RENAMED
|
@@ -11,19 +11,9 @@ import clientModules, { plugins } from '@app/frontend-stack-react/modules.js';
|
|
|
11
11
|
import { useChangeLanguage } from 'remix-i18next/react';
|
|
12
12
|
import { useTranslation } from 'react-i18next';
|
|
13
13
|
// @ts-ignore
|
|
14
|
-
import { i18nextInstance as i18next } from '@app/frontend-stack-react/i18n-localization/i18next.server.js';
|
|
15
|
-
// @ts-ignore
|
|
16
14
|
import { ErrorBoundary } from '@app/frontend-stack-react/entries/antui/components/ErrorBoundary';
|
|
17
15
|
import { LocaleContext } from './context';
|
|
18
|
-
|
|
19
|
-
export const loader = async ({ request }) => {
|
|
20
|
-
const locale = await i18next.getLocale(request);
|
|
21
|
-
return json({
|
|
22
|
-
__ENV__: publicEnv,
|
|
23
|
-
locale,
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
*/
|
|
16
|
+
|
|
27
17
|
export const handle = {
|
|
28
18
|
i18n: 'common',
|
|
29
19
|
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/* eslint-disable jest/no-hooks */
|
|
2
|
+
/* eslint-disable import/no-extraneous-dependencies */
|
|
3
|
+
import { beforeEach, describe, expect, it, jest } from '@jest/globals';
|
|
4
|
+
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
|
5
|
+
import { readJson, Tree, writeJson } from '@nx/devkit';
|
|
6
|
+
import * as devkit from '@nx/devkit';
|
|
7
|
+
import { addFrontendGenerator } from './generator';
|
|
8
|
+
import { FRAMEWORK_ANTUI } from '../../common/constants';
|
|
9
|
+
|
|
10
|
+
describe('addFrontendGenerator', () => {
|
|
11
|
+
let tree: Tree;
|
|
12
|
+
const options = { name: 'demo', framework: FRAMEWORK_ANTUI, ns: '', directory: '' };
|
|
13
|
+
|
|
14
|
+
const projectRoot = 'frontend-demo-server';
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
// Create an in-memory workspace
|
|
18
|
+
tree = createTreeWithEmptyWorkspace();
|
|
19
|
+
|
|
20
|
+
// Stub out generateFiles so we don't trigger file reading from the real templates folders.
|
|
21
|
+
jest.spyOn(devkit, 'generateFiles').mockImplementation(() => {});
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('should add missing dependencies and update config.json for antui', async () => {
|
|
25
|
+
// Simulate an existing package.json with no dependencies.
|
|
26
|
+
writeJson(tree, `${projectRoot}/package.json`, {
|
|
27
|
+
name: 'demo',
|
|
28
|
+
dependencies: {},
|
|
29
|
+
});
|
|
30
|
+
// Simulate an existing config.json with an empty modules array.
|
|
31
|
+
writeJson(tree, `${projectRoot}/config.json`, {
|
|
32
|
+
modules: [],
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
await addFrontendGenerator(tree, options);
|
|
36
|
+
|
|
37
|
+
// Read and verify package.json updates.
|
|
38
|
+
const pkg = readJson(tree, `${projectRoot}/package.json`);
|
|
39
|
+
|
|
40
|
+
expect(pkg.name).toBe('frontend-demo-server');
|
|
41
|
+
// Check that the key dependency is added.
|
|
42
|
+
expect(pkg.dependencies['@admin-layout/ant-design-pro']).toBeDefined();
|
|
43
|
+
expect(pkg.dependencies['@ant-design/static-style-extract']).toBeDefined();
|
|
44
|
+
expect(pkg.dependencies['@emotion/react']).toBeDefined();
|
|
45
|
+
expect(pkg.dependencies['antd']).toBeDefined();
|
|
46
|
+
expect(pkg).toMatchSnapshot();
|
|
47
|
+
|
|
48
|
+
// Read and verify config.json updates.
|
|
49
|
+
const config = readJson(tree, `${projectRoot}/config.json`);
|
|
50
|
+
|
|
51
|
+
expect(config.uiFramework).toBe(FRAMEWORK_ANTUI);
|
|
52
|
+
// Ensure that the module is added only once.
|
|
53
|
+
expect(config.modules.includes('@admin-layout/ant-design-pro')).toBeTruthy();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('should not override an already existing dependency version', async () => {
|
|
57
|
+
// Create an initial package.json that already defines a version for a dependency.
|
|
58
|
+
writeJson(tree, `${projectRoot}/package.json`, {
|
|
59
|
+
name: 'demo',
|
|
60
|
+
dependencies: {
|
|
61
|
+
antd: '1.0.0', // Already defined version
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
// Create a minimal config.json.
|
|
65
|
+
writeJson(tree, `${projectRoot}/config.json`, {
|
|
66
|
+
modules: [],
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
await addFrontendGenerator(tree, options);
|
|
70
|
+
|
|
71
|
+
const pkg = readJson(tree, `${projectRoot}/package.json`);
|
|
72
|
+
|
|
73
|
+
// Make sure the dependency already there was not overridden.
|
|
74
|
+
expect(pkg.dependencies.antd).toEqual('1.0.0');
|
|
75
|
+
// Ensure other expected dependencies have been added.
|
|
76
|
+
expect(pkg.dependencies['@admin-layout/ant-design-pro']).toBeDefined();
|
|
77
|
+
expect(pkg).toMatchSnapshot();
|
|
78
|
+
});
|
|
79
|
+
});
|
|
@@ -1,18 +1,88 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
/* eslint-disable no-param-reassign */
|
|
3
|
+
/* eslint-disable no-use-before-define */
|
|
4
|
+
import { formatFiles, generateFiles, Tree, updateJson } from '@nx/devkit';
|
|
2
5
|
import * as path from 'path';
|
|
3
6
|
import * as fs from 'node:fs';
|
|
4
7
|
import { deepMerge } from '@common-stack/rollup-vite-utils/lib/utils/setupConfig.cjs';
|
|
5
8
|
import { AddFrontendGeneratorSchema } from './schema';
|
|
6
9
|
import { isValid, getValid } from '../../utils';
|
|
7
10
|
import { FRAMEWORK_ANTUI, FRAMEWORK_CHAKRAUI, FRAMEWORK_TAILWINDUI } from '../../common/constants';
|
|
11
|
+
import pluginPkg from '../../common/package-releases/package.json' assert { type: 'json' };
|
|
8
12
|
|
|
9
13
|
const DEFAULT_FRAMEWORK = FRAMEWORK_ANTUI;
|
|
10
14
|
const DEFAULT_SERVER_NAME = 'frontend-server';
|
|
11
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Helper to retrieve a package version from pluginPkg.
|
|
18
|
+
* Throws an error if a version for packageName is not defined.
|
|
19
|
+
*/
|
|
20
|
+
function getPackageVersion(packageName: string): string {
|
|
21
|
+
// Read the generator's package.json. This file is updated using ncu,
|
|
22
|
+
// so the generator always picks up the latest dependency versions.
|
|
23
|
+
// const pluginPkgPath = path.resolve(__dirname, '../../common/package-releases/package.json');
|
|
24
|
+
// const pluginPkg = JSON.parse(fs.readFileSync(pluginPkgPath, 'utf-8'));
|
|
25
|
+
|
|
26
|
+
const version =
|
|
27
|
+
(pluginPkg.dependencies && pluginPkg.dependencies[packageName]) ||
|
|
28
|
+
(pluginPkg.devDependencies && pluginPkg.devDependencies[packageName]);
|
|
29
|
+
|
|
30
|
+
if (!version) {
|
|
31
|
+
throw new Error(`Version for package "${packageName}" not found in plugin package.json.`);
|
|
32
|
+
}
|
|
33
|
+
return version;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Helper to map an array of dependency names to an object where each key is a dependency
|
|
38
|
+
* and its value is obtained via getPackageVersion().
|
|
39
|
+
*/
|
|
40
|
+
function mapDependencies(depNames: string[]): Record<string, string> {
|
|
41
|
+
return depNames.reduce(
|
|
42
|
+
(acc, name) => {
|
|
43
|
+
acc[name] = getPackageVersion(name);
|
|
44
|
+
return acc;
|
|
45
|
+
},
|
|
46
|
+
{} as Record<string, string>,
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* A mapping of frameworks to dependency definitions.
|
|
52
|
+
* Each dependency's version is obtained dynamically from pluginPkg using a helper.
|
|
53
|
+
*/
|
|
54
|
+
const frameworkDependencyMap: {
|
|
55
|
+
[key: string]: { dependencies?: Record<string, string>; devDependencies?: Record<string, string> };
|
|
56
|
+
} = {
|
|
57
|
+
[FRAMEWORK_ANTUI]: {
|
|
58
|
+
dependencies: mapDependencies([
|
|
59
|
+
'@admin-layout/ant-design-pro',
|
|
60
|
+
'@ant-design/static-style-extract',
|
|
61
|
+
'@emotion/react',
|
|
62
|
+
'@emotion/server',
|
|
63
|
+
'@emotion/css',
|
|
64
|
+
'@emotion/styled',
|
|
65
|
+
'antd',
|
|
66
|
+
]),
|
|
67
|
+
},
|
|
68
|
+
[FRAMEWORK_CHAKRAUI]: {
|
|
69
|
+
dependencies: mapDependencies([
|
|
70
|
+
'@chakra-ui/react',
|
|
71
|
+
'framer-motion',
|
|
72
|
+
'@emotion/react',
|
|
73
|
+
'@emotion/server',
|
|
74
|
+
'@emotion/css',
|
|
75
|
+
'@emotion/styled',
|
|
76
|
+
]),
|
|
77
|
+
},
|
|
78
|
+
[FRAMEWORK_TAILWINDUI]: {
|
|
79
|
+
devDependencies: mapDependencies(['tailwindcss', 'postcss', 'autoprefixer']),
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
|
|
12
83
|
export async function addFrontendGenerator(tree: Tree, options: AddFrontendGeneratorSchema) {
|
|
13
84
|
const projectName = isValid(options.name) ? `frontend-${getValid(options.name)}-server` : DEFAULT_SERVER_NAME;
|
|
14
|
-
const configs: any = {...options, name: projectName};
|
|
15
|
-
|
|
85
|
+
const configs: any = { ...options, name: projectName };
|
|
16
86
|
return await generateFrontend(tree, configs);
|
|
17
87
|
}
|
|
18
88
|
|
|
@@ -20,65 +90,60 @@ export const generateFrontend = async (tree: Tree, options: any) => {
|
|
|
20
90
|
let projectName = getValid(options.name) ?? DEFAULT_SERVER_NAME;
|
|
21
91
|
const projectRoot = isValid(options.directory) ? `${getValid(options.directory)}/${projectName}` : projectName;
|
|
22
92
|
projectName = isValid(options.ns) ? `${getValid(options.ns)}-${projectName}` : projectName;
|
|
23
|
-
|
|
24
|
-
|
|
93
|
+
|
|
25
94
|
const framework = getValid(options.framework) ?? DEFAULT_FRAMEWORK;
|
|
26
95
|
console.log('UI framework specified: ', framework);
|
|
27
|
-
|
|
28
|
-
// resetProject(`${basePath}/${projectRoot}`);
|
|
29
|
-
|
|
30
|
-
// addProjectConfiguration(tree, framework, {
|
|
31
|
-
// root: projectRoot,
|
|
32
|
-
// projectType: 'library',
|
|
33
|
-
// sourceRoot: projectSrc,
|
|
34
|
-
// targets: {},
|
|
35
|
-
// });
|
|
36
|
-
|
|
96
|
+
|
|
37
97
|
generateFiles(tree, path.join(__dirname, 'templates'), projectRoot, {});
|
|
38
|
-
generateFiles(tree, path.join(__dirname, 'frameworks', framework),
|
|
98
|
+
generateFiles(tree, path.join(__dirname, 'frameworks', framework), projectRoot, options);
|
|
99
|
+
|
|
39
100
|
updateJson(tree, `${projectRoot}/package.json`, (packageJson) => {
|
|
40
|
-
packageJson
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
packageJson['dependencies']["@emotion/react"] = "^11.10.0";
|
|
53
|
-
packageJson['dependencies']["@emotion/server"] = "^11.10.0";
|
|
54
|
-
packageJson['dependencies']["@emotion/css"] = "^11.10.0";
|
|
55
|
-
packageJson['dependencies']["@emotion/styled"] = "^11.10.4";
|
|
56
|
-
|
|
57
|
-
} else if (framework === FRAMEWORK_TAILWINDUI) {
|
|
58
|
-
packageJson['devDependencies']["tailwindcss"] = "^3.4.10";
|
|
59
|
-
packageJson['devDependencies']["postcss"] = "^8.4.41";
|
|
60
|
-
packageJson['devDependencies']["autoprefixer"] = "^10.4.20";
|
|
101
|
+
packageJson.name = projectName;
|
|
102
|
+
packageJson.dependencies = packageJson.dependencies || {};
|
|
103
|
+
packageJson.devDependencies = packageJson.devDependencies || {};
|
|
104
|
+
|
|
105
|
+
const dependencyOverrides = frameworkDependencyMap[framework] || {};
|
|
106
|
+
|
|
107
|
+
if (dependencyOverrides.dependencies) {
|
|
108
|
+
Object.entries(dependencyOverrides.dependencies).forEach(([pkg, version]) => {
|
|
109
|
+
if (!packageJson.dependencies[pkg]) {
|
|
110
|
+
packageJson.dependencies[pkg] = version;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
61
113
|
}
|
|
62
|
-
|
|
114
|
+
|
|
115
|
+
if (dependencyOverrides.devDependencies) {
|
|
116
|
+
Object.entries(dependencyOverrides.devDependencies).forEach(([pkg, version]) => {
|
|
117
|
+
if (!packageJson.devDependencies[pkg]) {
|
|
118
|
+
packageJson.devDependencies[pkg] = version;
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
63
123
|
return packageJson;
|
|
64
124
|
});
|
|
125
|
+
|
|
65
126
|
updateJson(tree, `${projectRoot}/config.json`, (configJson) => {
|
|
66
|
-
configJson
|
|
127
|
+
configJson.uiFramework = framework;
|
|
67
128
|
if (framework === FRAMEWORK_ANTUI) {
|
|
68
|
-
configJson
|
|
129
|
+
if (!configJson.modules.includes('@admin-layout/ant-design-pro')) {
|
|
130
|
+
configJson.modules.push('@admin-layout/ant-design-pro');
|
|
131
|
+
}
|
|
69
132
|
} else if (framework === FRAMEWORK_CHAKRAUI) {
|
|
70
|
-
configJson
|
|
133
|
+
if (!configJson.modules.includes('@admin-layout/chakra-design-pro')) {
|
|
134
|
+
configJson.modules.push('@admin-layout/chakra-design-pro');
|
|
135
|
+
}
|
|
71
136
|
}
|
|
72
137
|
|
|
73
138
|
if (options['config.json']) {
|
|
74
|
-
const
|
|
75
|
-
configJson = deepMerge(configJson,
|
|
139
|
+
const additionalConfigs = options['config.json'];
|
|
140
|
+
configJson = deepMerge(configJson, additionalConfigs);
|
|
76
141
|
}
|
|
77
142
|
|
|
78
143
|
return configJson;
|
|
79
144
|
});
|
|
80
145
|
|
|
81
146
|
await formatFiles(tree);
|
|
82
|
-
}
|
|
147
|
+
};
|
|
83
148
|
|
|
84
149
|
export default addFrontendGenerator;
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"URI": "URI",
|
|
16
16
|
"URIInput": "URI | UriComponents"
|
|
17
17
|
},
|
|
18
|
+
"enumPrefix": false,
|
|
18
19
|
"enumValues": {
|
|
19
20
|
"ConfigurationScope": "@workbench-stack/core/lib/interfaces/configuration/configuration.js#ConfigurationScope",
|
|
20
21
|
"ConfigurationTarget": "../configuration#ConfigurationTarget"
|
|
@@ -47,6 +48,7 @@
|
|
|
47
48
|
"URI": "URI",
|
|
48
49
|
"URIInput": "URI | UriComponents"
|
|
49
50
|
},
|
|
51
|
+
"enumPrefix": false,
|
|
50
52
|
"withHooks": true,
|
|
51
53
|
"typesPrefix": "I",
|
|
52
54
|
"noNamespaces": true,
|
|
@@ -67,6 +69,21 @@
|
|
|
67
69
|
},
|
|
68
70
|
"typescript-react-apollo"
|
|
69
71
|
]
|
|
72
|
+
},
|
|
73
|
+
"packages/common/src/generated/introspection-result.ts": {
|
|
74
|
+
"schema": "%discoveredSchemas%",
|
|
75
|
+
"documents": "%discoveredDocuments%",
|
|
76
|
+
"config": {
|
|
77
|
+
"typesPrefix": "I"
|
|
78
|
+
},
|
|
79
|
+
"plugins": [
|
|
80
|
+
{
|
|
81
|
+
"add": {
|
|
82
|
+
"content": ["/* tslint:disable */"]
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"fragment-matcher"
|
|
86
|
+
]
|
|
70
87
|
}
|
|
71
88
|
}
|
|
72
89
|
}
|