@common-stack/generate-plugin 7.0.4-alpha.1 → 7.0.4-alpha.3
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/generators/add-fullstack/files/package.json +1 -1
- package/lib/generators/add-fullstack/files/rollup.config.base.mjs +45 -22
- package/lib/generators/add-fullstack/generator.cjs +7 -1
- package/lib/generators/add-fullstack/generator.cjs.map +1 -1
- package/lib/generators/add-fullstack/generator.mjs +7 -1
- package/lib/generators/add-fullstack/generator.mjs.map +1 -1
- package/lib/generators/add-fullstack/schema.d.ts +10 -0
- package/lib/generators/add-fullstack/updates/nxSetup.cjs +113 -57
- package/lib/generators/add-fullstack/updates/nxSetup.cjs.map +1 -1
- package/lib/generators/add-fullstack/updates/nxSetup.d.ts +1 -1
- package/lib/generators/add-fullstack/updates/nxSetup.mjs +113 -57
- package/lib/generators/add-fullstack/updates/nxSetup.mjs.map +1 -1
- package/lib/generators/add-package/files/browser/rollup.config.mjs +1 -1
- package/lib/generators/add-package/files/browser/tsconfig.json +15 -27
- package/lib/generators/add-package/files/client/rollup.config.mjs +30 -25
- package/lib/generators/add-package/files/client/tsconfig.json +13 -26
- package/lib/generators/add-package/files/core/rollup.config.mjs +33 -61
- package/lib/generators/add-package/files/core/tsconfig.json +12 -21
- package/lib/generators/add-package/files/server/rollup.config.mjs +31 -24
- package/lib/generators/add-package/files/server/tsconfig.json +15 -25
- package/lib/generators/add-package/generator.cjs +53 -11
- package/lib/generators/add-package/generator.cjs.map +1 -1
- package/lib/generators/add-package/generator.d.ts +4 -1
- package/lib/generators/add-package/generator.mjs +53 -11
- package/lib/generators/add-package/generator.mjs.map +1 -1
- package/package.json +2 -2
- package/src/generators/add-fullstack/files/package.json +1 -1
- package/src/generators/add-fullstack/files/rollup.config.base.mjs +45 -22
- package/src/generators/add-fullstack/generator.ts +8 -1
- package/src/generators/add-fullstack/schema.ts +10 -0
- package/src/generators/add-fullstack/updates/nxSetup.ts +123 -73
- package/src/generators/add-package/files/browser/rollup.config.mjs +1 -1
- package/src/generators/add-package/files/browser/tsconfig.json +15 -27
- package/src/generators/add-package/files/client/rollup.config.mjs +30 -25
- package/src/generators/add-package/files/client/tsconfig.json +13 -26
- package/src/generators/add-package/files/core/rollup.config.mjs +33 -61
- package/src/generators/add-package/files/core/tsconfig.json +12 -21
- package/src/generators/add-package/files/server/rollup.config.mjs +31 -24
- package/src/generators/add-package/files/server/tsconfig.json +15 -25
- package/src/generators/add-package/generator.ts +75 -17
- package/lib/generators/add-package/files/browser/webpack.config.js +0 -71
- package/lib/generators/add-package/files/client/webpack.config.js +0 -72
- package/lib/generators/add-package/files/core/webpack.config.js +0 -53
- package/src/generators/add-package/files/browser/webpack.config.js +0 -71
- package/src/generators/add-package/files/client/webpack.config.js +0 -72
- package/src/generators/add-package/files/core/webpack.config.js +0 -53
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var tslib=require('tslib'),devkit=require('@nx/devkit'),path=require('path'),index=require('../../utils/index.cjs'),filesConfig=require('../../utils/filesConfig.cjs'),syncConfig=require('../../utils/syncConfig.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);function addPackageGenerator(tree, options) {
|
|
1
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var tslib=require('tslib'),devkit=require('@nx/devkit'),path=require('path'),index=require('../../utils/index.cjs'),filesConfig=require('../../utils/filesConfig.cjs'),syncConfig=require('../../utils/syncConfig.cjs'),copyDotfiles=require('../../utils/copyDotfiles.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);function addPackageGenerator(tree, options) {
|
|
2
2
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
3
3
|
if (!index.isValid(options.name)) {
|
|
4
4
|
console.error('Package name can not be empty, please try again!');
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
generatePackage(tree, Object.assign(Object.assign({}, options), { type: packageType.toLocaleLowerCase() }), true);
|
|
15
15
|
}
|
|
16
16
|
else {
|
|
17
|
-
packages.forEach(pkg => {
|
|
17
|
+
packages.forEach((pkg) => {
|
|
18
18
|
const configs = Object.assign(Object.assign({}, options), { type: pkg });
|
|
19
19
|
generatePackage(tree, configs, true);
|
|
20
20
|
});
|
|
@@ -31,20 +31,62 @@
|
|
|
31
31
|
// await formatFiles(tree);
|
|
32
32
|
// }
|
|
33
33
|
const generatePackage = (tree_1, options_1, ...args_1) => tslib.__awaiter(void 0, [tree_1, options_1, ...args_1], void 0, function* (tree, options, cmdLine = false) {
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
var _a, _b;
|
|
35
|
+
const packageName = (_a = index.getValid(options.name)) !== null && _a !== void 0 ? _a : 'empty-package';
|
|
36
|
+
let projectRoot = '';
|
|
37
|
+
if (index.isValid(options.directory)) {
|
|
38
|
+
projectRoot = `${index.getValid(options.directory)}/${packageName}`;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
projectRoot = `packages/${packageName}`;
|
|
42
|
+
}
|
|
43
|
+
// Namespace the package if provided
|
|
44
|
+
let fullPackageName = packageName;
|
|
45
|
+
if (index.isValid(options.ns)) {
|
|
46
|
+
fullPackageName = `${index.getValid(options.ns)}-${packageName}`;
|
|
47
|
+
}
|
|
48
|
+
// Calculate the offset from root for relative paths in templates
|
|
49
|
+
const offset = devkit.offsetFromRoot(projectRoot);
|
|
50
|
+
// Define template options with offsetFromRoot for relative paths
|
|
51
|
+
const templateOptions = Object.assign(Object.assign({}, options), { name: fullPackageName, offsetFromRoot: offset, template: '', dot: '.' });
|
|
52
|
+
// Determine the package type and generate files accordingly
|
|
53
|
+
const packageType = (_b = index.getValid(options.type)) !== null && _b !== void 0 ? _b : 'core';
|
|
54
|
+
console.log(`Generating ${packageType} package: ${fullPackageName} at ${projectRoot}`);
|
|
55
|
+
// Generate the appropriate package files based on type
|
|
56
|
+
switch (packageType) {
|
|
57
|
+
case 'browser':
|
|
58
|
+
devkit.generateFiles(tree, path__namespace.join(__dirname, 'files', 'browser'), projectRoot, templateOptions);
|
|
59
|
+
break;
|
|
60
|
+
case 'client':
|
|
61
|
+
devkit.generateFiles(tree, path__namespace.join(__dirname, 'files', 'client'), projectRoot, templateOptions);
|
|
62
|
+
break;
|
|
63
|
+
case 'server':
|
|
64
|
+
devkit.generateFiles(tree, path__namespace.join(__dirname, 'files', 'server'), projectRoot, templateOptions);
|
|
65
|
+
break;
|
|
66
|
+
case 'core':
|
|
67
|
+
default:
|
|
68
|
+
devkit.generateFiles(tree, path__namespace.join(__dirname, 'files', 'core'), projectRoot, templateOptions);
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
// Rename underscore-prefixed files to dot files
|
|
72
|
+
copyDotfiles.renameDotFiles(tree, projectRoot);
|
|
73
|
+
// Copy .npmrc from the main project root if exists
|
|
74
|
+
const mainProjectRoot = options.projectRoot || '';
|
|
75
|
+
copyDotfiles.copyNpmrc(tree, mainProjectRoot, projectRoot);
|
|
76
|
+
// Update package.json with the correct package name
|
|
77
|
+
devkit.updateJson(tree, `${projectRoot}/package.json`, (packageJson) => {
|
|
78
|
+
packageJson.name = fullPackageName;
|
|
41
79
|
return packageJson;
|
|
42
80
|
});
|
|
43
81
|
if (cmdLine) {
|
|
44
|
-
syncConfig.syncConfig(tree,
|
|
82
|
+
syncConfig.syncConfig(tree, projectRoot, options);
|
|
45
83
|
}
|
|
46
84
|
else {
|
|
47
|
-
filesConfig.processFiles(tree,
|
|
85
|
+
filesConfig.processFiles(tree, projectRoot, options);
|
|
48
86
|
yield devkit.formatFiles(tree);
|
|
49
87
|
}
|
|
88
|
+
return {
|
|
89
|
+
packageName: fullPackageName,
|
|
90
|
+
projectRoot,
|
|
91
|
+
};
|
|
50
92
|
});exports.addPackageGenerator=addPackageGenerator;exports.default=addPackageGenerator;exports.generatePackage=generatePackage;//# sourceMappingURL=generator.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.cjs","sources":["../../../src/generators/add-package/generator.ts"],"sourcesContent":[null],"names":["isValid","getValid","formatFiles","__awaiter","generateFiles","path","updateJson","syncConfig","processFiles"],"mappings":"
|
|
1
|
+
{"version":3,"file":"generator.cjs","sources":["../../../src/generators/add-package/generator.ts"],"sourcesContent":[null],"names":["isValid","getValid","formatFiles","__awaiter","offsetFromRoot","generateFiles","path","renameDotFiles","copyNpmrc","updateJson","syncConfig","processFiles"],"mappings":"irBASsB,SAAA,mBAAmB,CAAC,IAAU,EAAE,OAAkC,EAAA;;QACpF,IAAI,CAACA,aAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;AACxB,YAAA,OAAO,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC;YAClE,OAAO;SACV;QAED,MAAM,QAAQ,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;QACzD,MAAM,WAAW,GAAGC,cAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QAClD,IAAI,WAAW,IAAI,WAAW,CAAC,iBAAiB,EAAE,KAAK,KAAK,EAAE;YAC1D,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;AACjC,gBAAA,OAAO,CAAC,KAAK,CAAC,gFAAgF,CAAC,CAAC;gBAChG,O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C,CAAC;YAC3F,MAAM;AACV,QAAA,KAAK,MAAM,CAAC;AACZ,QAAA;AACI,YAAAD,oBAAa,CAAC,IAAI,EAAEC,eAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,WAAW,EAAE,eAAe,CAAC,CAAC;YACzF,MAAM;KACb;;AAGD,IAAAC,2BAAc,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;;AAGlC,IAAA,MAAM,eAAe,GAAG,OAAO,CAAC,WAAW,IAAI,EAAE,CAAC;AAClD,IAAAC,sBAAS,CAAC,IAAI,EAAE,eAAe,EAAE,WAAW,CAAC,CAAC;;IAG9CC,iBAAU,CAAC,IAAI,EAAE,CAAG,EAAA,WAAW,eAAe,EAAE,CAAC,WAAW,KAAI;AAC5D,QAAA,WAAW,CAAC,IAAI,GAAG,eAAe,CAAC;AACnC,QAAA,OAAO,WAAW,CAAC;AACvB,KAAC,CAAC,CAAC;IAEH,IAAI,OAAO,EAAE;AACT,QAAAC,qBAAU,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;KAC1C;SAAM;AACH,QAAAC,wBAAY,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;AACzC,QAAA,MAAMT,kBAAW,CAAC,IAAI,CAAC,CAAC;KAC3B;IAED,OAAO;AACH,QAAA,WAAW,EAAE,eAAe;QAC5B,WAAW;KACd,CAAC;AACN,CAAC"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
2
|
import { AddPackageGeneratorSchema } from './schema';
|
|
3
3
|
export declare function addPackageGenerator(tree: Tree, options: AddPackageGeneratorSchema): Promise<void>;
|
|
4
|
-
export declare const generatePackage: (tree: Tree, options: any, cmdLine?: boolean) => Promise<
|
|
4
|
+
export declare const generatePackage: (tree: Tree, options: any, cmdLine?: boolean) => Promise<{
|
|
5
|
+
packageName: string;
|
|
6
|
+
projectRoot: string;
|
|
7
|
+
}>;
|
|
5
8
|
export default addPackageGenerator;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {__awaiter}from'tslib';import {formatFiles,generateFiles,updateJson}from'@nx/devkit';import*as path from'path';import {isValid,getValid}from'../../utils/index.mjs';import {processFiles}from'../../utils/filesConfig.mjs';import {syncConfig}from'../../utils/syncConfig.mjs';function addPackageGenerator(tree, options) {
|
|
1
|
+
import {__awaiter}from'tslib';import {formatFiles,offsetFromRoot,generateFiles,updateJson}from'@nx/devkit';import*as path from'path';import {isValid,getValid}from'../../utils/index.mjs';import {processFiles}from'../../utils/filesConfig.mjs';import {syncConfig}from'../../utils/syncConfig.mjs';import {renameDotFiles,copyNpmrc}from'../../utils/copyDotfiles.mjs';function addPackageGenerator(tree, options) {
|
|
2
2
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3
3
|
if (!isValid(options.name)) {
|
|
4
4
|
console.error('Package name can not be empty, please try again!');
|
|
@@ -14,7 +14,7 @@ import {__awaiter}from'tslib';import {formatFiles,generateFiles,updateJson}from'
|
|
|
14
14
|
generatePackage(tree, Object.assign(Object.assign({}, options), { type: packageType.toLocaleLowerCase() }), true);
|
|
15
15
|
}
|
|
16
16
|
else {
|
|
17
|
-
packages.forEach(pkg => {
|
|
17
|
+
packages.forEach((pkg) => {
|
|
18
18
|
const configs = Object.assign(Object.assign({}, options), { type: pkg });
|
|
19
19
|
generatePackage(tree, configs, true);
|
|
20
20
|
});
|
|
@@ -31,20 +31,62 @@ import {__awaiter}from'tslib';import {formatFiles,generateFiles,updateJson}from'
|
|
|
31
31
|
// await formatFiles(tree);
|
|
32
32
|
// }
|
|
33
33
|
const generatePackage = (tree_1, options_1, ...args_1) => __awaiter(void 0, [tree_1, options_1, ...args_1], void 0, function* (tree, options, cmdLine = false) {
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
var _a, _b;
|
|
35
|
+
const packageName = (_a = getValid(options.name)) !== null && _a !== void 0 ? _a : 'empty-package';
|
|
36
|
+
let projectRoot = '';
|
|
37
|
+
if (isValid(options.directory)) {
|
|
38
|
+
projectRoot = `${getValid(options.directory)}/${packageName}`;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
projectRoot = `packages/${packageName}`;
|
|
42
|
+
}
|
|
43
|
+
// Namespace the package if provided
|
|
44
|
+
let fullPackageName = packageName;
|
|
45
|
+
if (isValid(options.ns)) {
|
|
46
|
+
fullPackageName = `${getValid(options.ns)}-${packageName}`;
|
|
47
|
+
}
|
|
48
|
+
// Calculate the offset from root for relative paths in templates
|
|
49
|
+
const offset = offsetFromRoot(projectRoot);
|
|
50
|
+
// Define template options with offsetFromRoot for relative paths
|
|
51
|
+
const templateOptions = Object.assign(Object.assign({}, options), { name: fullPackageName, offsetFromRoot: offset, template: '', dot: '.' });
|
|
52
|
+
// Determine the package type and generate files accordingly
|
|
53
|
+
const packageType = (_b = getValid(options.type)) !== null && _b !== void 0 ? _b : 'core';
|
|
54
|
+
console.log(`Generating ${packageType} package: ${fullPackageName} at ${projectRoot}`);
|
|
55
|
+
// Generate the appropriate package files based on type
|
|
56
|
+
switch (packageType) {
|
|
57
|
+
case 'browser':
|
|
58
|
+
generateFiles(tree, path.join(__dirname, 'files', 'browser'), projectRoot, templateOptions);
|
|
59
|
+
break;
|
|
60
|
+
case 'client':
|
|
61
|
+
generateFiles(tree, path.join(__dirname, 'files', 'client'), projectRoot, templateOptions);
|
|
62
|
+
break;
|
|
63
|
+
case 'server':
|
|
64
|
+
generateFiles(tree, path.join(__dirname, 'files', 'server'), projectRoot, templateOptions);
|
|
65
|
+
break;
|
|
66
|
+
case 'core':
|
|
67
|
+
default:
|
|
68
|
+
generateFiles(tree, path.join(__dirname, 'files', 'core'), projectRoot, templateOptions);
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
// Rename underscore-prefixed files to dot files
|
|
72
|
+
renameDotFiles(tree, projectRoot);
|
|
73
|
+
// Copy .npmrc from the main project root if exists
|
|
74
|
+
const mainProjectRoot = options.projectRoot || '';
|
|
75
|
+
copyNpmrc(tree, mainProjectRoot, projectRoot);
|
|
76
|
+
// Update package.json with the correct package name
|
|
77
|
+
updateJson(tree, `${projectRoot}/package.json`, (packageJson) => {
|
|
78
|
+
packageJson.name = fullPackageName;
|
|
41
79
|
return packageJson;
|
|
42
80
|
});
|
|
43
81
|
if (cmdLine) {
|
|
44
|
-
syncConfig(tree,
|
|
82
|
+
syncConfig(tree, projectRoot, options);
|
|
45
83
|
}
|
|
46
84
|
else {
|
|
47
|
-
processFiles(tree,
|
|
85
|
+
processFiles(tree, projectRoot, options);
|
|
48
86
|
yield formatFiles(tree);
|
|
49
87
|
}
|
|
88
|
+
return {
|
|
89
|
+
packageName: fullPackageName,
|
|
90
|
+
projectRoot,
|
|
91
|
+
};
|
|
50
92
|
});export{addPackageGenerator,addPackageGenerator as default,generatePackage};//# sourceMappingURL=generator.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.mjs","sources":["../../../src/generators/add-package/generator.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generator.mjs","sources":["../../../src/generators/add-package/generator.ts"],"sourcesContent":[null],"names":[],"mappings":"yWASsB,SAAA,mBAAmB,CAAC,IAAU,EAAE,OAAkC,EAAA;;QACpF,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;AACxB,YAAA,OAAO,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC;YAClE,OAAO;SACV;QAED,MAAM,QAAQ,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;QACzD,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QAClD,IAAI,WAAW,IAAI,WAAW,CAAC,iBAAiB,EAAE,KAAK,KAAK,EAAE;YAC1D,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IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,WAAW,EAAE,eAAe,CAAC,CAAC;YAC3F,MAAM;AACV,QAAA,KAAK,MAAM,CAAC;AACZ,QAAA;AACI,YAAA,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,WAAW,EAAE,eAAe,CAAC,CAAC;YACzF,MAAM;KACb;;AAGD,IAAA,cAAc,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;;AAGlC,IAAA,MAAM,eAAe,GAAG,OAAO,CAAC,WAAW,IAAI,EAAE,CAAC;AAClD,IAAA,SAAS,CAAC,IAAI,EAAE,eAAe,EAAE,WAAW,CAAC,CAAC;;IAG9C,UAAU,CAAC,IAAI,EAAE,CAAG,EAAA,WAAW,eAAe,EAAE,CAAC,WAAW,KAAI;AAC5D,QAAA,WAAW,CAAC,IAAI,GAAG,eAAe,CAAC;AACnC,QAAA,OAAO,WAAW,CAAC;AACvB,KAAC,CAAC,CAAC;IAEH,IAAI,OAAO,EAAE;AACT,QAAA,UAAU,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;KAC1C;SAAM;AACH,QAAA,YAAY,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;AACzC,QAAA,MAAM,WAAW,CAAC,IAAI,CAAC,CAAC;KAC3B;IAED,OAAO;AACH,QAAA,WAAW,EAAE,eAAe;QAC5B,WAAW;KACd,CAAC;AACN,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@common-stack/generate-plugin",
|
|
3
|
-
"version": "7.0.4-alpha.
|
|
3
|
+
"version": "7.0.4-alpha.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./lib/index.mjs",
|
|
6
6
|
"typings": "./lib/index.d.ts",
|
|
@@ -26,5 +26,5 @@
|
|
|
26
26
|
},
|
|
27
27
|
"executors": "./executors.json",
|
|
28
28
|
"generators": "./generators.json",
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "16fbc2994452790ece9dbf63fe19ea6d6f9ed869"
|
|
30
30
|
}
|
|
@@ -145,7 +145,7 @@
|
|
|
145
145
|
"@babel/register": "^7.18.9",
|
|
146
146
|
"@babel/runtime": "^7.20.1",
|
|
147
147
|
"@common-stack/env-list-loader": "7.0.4-alpha.0",
|
|
148
|
-
"@common-stack/generate-plugin": "7.0.4-alpha.
|
|
148
|
+
"@common-stack/generate-plugin": "7.0.4-alpha.2",
|
|
149
149
|
"@common-stack/rollup-vite-utils": "7.0.4-alpha.0",
|
|
150
150
|
"@emotion/babel-plugin": "^11.11.0",
|
|
151
151
|
"@graphql-codegen/add": "^5.0.3",
|
|
@@ -2,16 +2,22 @@
|
|
|
2
2
|
import graphql from '@rollup/plugin-graphql';
|
|
3
3
|
import image from '@rollup/plugin-image';
|
|
4
4
|
import typescript from '@rollup/plugin-typescript';
|
|
5
|
+
import esbuild from 'rollup-plugin-esbuild'
|
|
5
6
|
import { string } from 'rollup-plugin-string';
|
|
6
7
|
import svg from 'rollup-plugin-svg';
|
|
7
8
|
import { copy } from '@web/rollup-plugin-copy';
|
|
9
|
+
import json from '@rollup/plugin-json';
|
|
8
10
|
import modifyLibFilesPlugin from '@common-stack/rollup-vite-utils/lib/rollup/rollupPluginModifyLibFiles.js';
|
|
9
11
|
import generateJsonFromObject from '@common-stack/rollup-vite-utils/lib/rollup/rollupPluginGenerateJson.js';
|
|
10
12
|
import addJsExtensionToImportsPlugin from '@common-stack/rollup-vite-utils/lib/rollup/rollupPluginAddJsExtension.js';
|
|
11
13
|
import { ignoreCssUrlPlugin } from '@common-stack/rollup-vite-utils/lib/rollup/pluginIgnore.js';
|
|
12
14
|
// Define any additional plugins specific to this bundle
|
|
13
15
|
const additionalPlugins = [
|
|
14
|
-
copy({
|
|
16
|
+
copy({
|
|
17
|
+
patterns: ['**/cdm-locales/**/*', '**/*.gql', '**/**/*.graphql', '**/styles/**/*', '**/templates/**/*', '**/css/**/*'],
|
|
18
|
+
rootDir: './src',
|
|
19
|
+
}),
|
|
20
|
+
json(),
|
|
15
21
|
];
|
|
16
22
|
|
|
17
23
|
function deepMergeConfigs(baseConfig, specificConfig) {
|
|
@@ -37,37 +43,54 @@ const baseConfig = {
|
|
|
37
43
|
addJsExtensionToImportsPlugin({
|
|
38
44
|
packages: '*',
|
|
39
45
|
needToAddIndexJs: [],
|
|
40
|
-
|
|
46
|
+
// exclude fs/promises from modifying
|
|
47
|
+
excludeImports: ['@emotion/react/jsx-runtime', 'fs/promises', '@apollo/server*'],
|
|
41
48
|
}),
|
|
42
|
-
typescript(), //
|
|
49
|
+
typescript(), // Initially include the TypeScript plugin
|
|
43
50
|
ignoreCssUrlPlugin(),
|
|
44
|
-
modifyLibFilesPlugin({
|
|
45
|
-
include: ['**/**/compute.js'], // Adjust to target specific files or patterns
|
|
46
|
-
outputDir: 'lib', // Ensure this matches your actual output directory
|
|
47
|
-
}),
|
|
48
|
-
generateJsonFromObject({}),
|
|
49
|
-
|
|
50
51
|
...additionalPlugins,
|
|
51
52
|
],
|
|
52
53
|
external: (id) => !/^[./]/.test(id),
|
|
53
54
|
globals: { react: 'React' },
|
|
54
55
|
};
|
|
55
56
|
|
|
56
|
-
//
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
// Updated createRollupConfig function to accept an options object as the second parameter.
|
|
58
|
+
// If useEsbuild is true, the TypeScript plugin is removed completely and replaced with the esbuild plugin.
|
|
59
|
+
function createRollupConfig(specificOverrides, options = {}) {
|
|
60
|
+
const { useEsbuild, isWatchMode, generateRoutesJSON } = options;
|
|
61
|
+
const config = deepMergeConfigs(baseConfig, specificOverrides);
|
|
59
62
|
|
|
60
|
-
//
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
63
|
+
// Conditionally add both modifyLibFilesPlugin and generateJsonFromObject plugins if generateRoutesJSON option is provided.
|
|
64
|
+
if (generateRoutesJSON) {
|
|
65
|
+
// Add modifyLibFilesPlugin with predetermined configuration.
|
|
66
|
+
config.plugins.push(modifyLibFilesPlugin({
|
|
67
|
+
include: ['**/**/compute.js'], // Adjust to target specific files or patterns
|
|
68
|
+
outputDir: 'lib', // Ensure this matches your actual output directory
|
|
69
|
+
}));
|
|
70
|
+
// Allow generateRoutesJSON to be an object with plugin configuration or simply a boolean.
|
|
71
|
+
const jsonConfig = typeof generateRoutesJSON === 'object' ? generateRoutesJSON : {};
|
|
72
|
+
config.plugins.push(generateJsonFromObject(jsonConfig));
|
|
73
|
+
}
|
|
70
74
|
|
|
75
|
+
if (useEsbuild) {
|
|
76
|
+
// Remove the TypeScript plugin completely.
|
|
77
|
+
config.plugins = config.plugins.filter((plugin) => plugin.name !== 'typescript');
|
|
78
|
+
// Add the esbuild plugin only. Note: The "watch" option is removed as it's not supported by esbuild.
|
|
79
|
+
config.plugins.push(esbuild({
|
|
80
|
+
target: 'es2017', // Adjust the target as needed
|
|
81
|
+
}));
|
|
82
|
+
} else {
|
|
83
|
+
// Retain the TypeScript plugin and adjust its options based on watch mode.
|
|
84
|
+
config.plugins = config.plugins.map((plugin) => {
|
|
85
|
+
if (plugin.name === 'typescript') {
|
|
86
|
+
return typescript({
|
|
87
|
+
...plugin.options,
|
|
88
|
+
noEmitOnError: !isWatchMode, // Adjust based on watch mode
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return plugin;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
71
94
|
return config;
|
|
72
95
|
}
|
|
73
96
|
|
|
@@ -31,6 +31,9 @@ import { addMoleculerGenerator as generateMoleculer } from '../add-moleculer/gen
|
|
|
31
31
|
import { addPackageGenerator as generatePackage } from '../add-package/generator';
|
|
32
32
|
|
|
33
33
|
export async function addFullstackGenerator(tree: Tree, options: AddFullstackGeneratorSchema) {
|
|
34
|
+
// Immediately set the environment variable to skip NX config
|
|
35
|
+
process.env.SKIP_NX_CONFIG = 'true';
|
|
36
|
+
|
|
34
37
|
let projectPath = options.path || '';
|
|
35
38
|
if (projectPath !== '') {
|
|
36
39
|
const basePath = process.cwd();
|
|
@@ -90,7 +93,11 @@ export async function addFullstackGenerator(tree: Tree, options: AddFullstackGen
|
|
|
90
93
|
}
|
|
91
94
|
}
|
|
92
95
|
|
|
93
|
-
//
|
|
96
|
+
// Setup Nx config with AWS credentials
|
|
97
|
+
// Allow skipping via environment variable
|
|
98
|
+
if (options.skipNxConfig) {
|
|
99
|
+
process.env.SKIP_NX_CONFIG = 'true';
|
|
100
|
+
}
|
|
94
101
|
await setupNxConfig(tree, projectRoot);
|
|
95
102
|
|
|
96
103
|
// Setup git and commit files
|
|
@@ -3,93 +3,143 @@ import * as path from 'path';
|
|
|
3
3
|
import * as readline from 'readline';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Sets up Nx configuration with optional AWS credentials
|
|
7
7
|
*/
|
|
8
8
|
export async function setupNxConfig(tree: Tree, projectRoot: string) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
9
|
+
console.log('\nAWS Configuration for Nx Cache');
|
|
10
|
+
console.log('=============================');
|
|
11
|
+
console.log('This project uses AWS S3 for remote caching with Nx.');
|
|
12
|
+
console.log('Please provide your AWS credentials or press Enter to skip for now.');
|
|
13
|
+
|
|
14
|
+
// Basic configuration without AWS credentials
|
|
15
|
+
const basicConfig = {
|
|
16
|
+
tasksRunnerOptions: {
|
|
17
|
+
default: {
|
|
18
|
+
runner: 'nx/tasks-runners/default',
|
|
19
|
+
options: {
|
|
20
|
+
cacheableOperations: ['build', 'test', 'lint'],
|
|
21
|
+
accessibleHosts: ['https://registry.npmjs.org'],
|
|
22
|
+
useDaemonProcess: false,
|
|
23
|
+
parallel: 3,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const nxJsonPath = path.join(projectRoot, 'nx.json');
|
|
30
|
+
|
|
31
|
+
// Safe prompt function with timeout that returns a string
|
|
32
|
+
const askWithTimeout = (rl: readline.Interface, question: string, timeoutMs = 10000): Promise<string> => {
|
|
33
|
+
return new Promise<string>((resolve) => {
|
|
34
|
+
let resolved = false;
|
|
35
|
+
|
|
36
|
+
const timeout = setTimeout(() => {
|
|
37
|
+
if (!resolved) {
|
|
38
|
+
resolved = true;
|
|
39
|
+
console.log(`\nTimeout waiting for input. Skipping.`);
|
|
40
|
+
resolve('');
|
|
41
|
+
}
|
|
42
|
+
}, timeoutMs);
|
|
43
|
+
|
|
44
|
+
rl.question(question, (answer: string) => {
|
|
45
|
+
if (!resolved) {
|
|
46
|
+
resolved = true;
|
|
47
|
+
clearTimeout(timeout);
|
|
48
|
+
resolve(answer);
|
|
49
|
+
}
|
|
42
50
|
});
|
|
43
51
|
});
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
let rl: readline.Interface | undefined;
|
|
55
|
+
try {
|
|
56
|
+
rl = readline.createInterface({
|
|
57
|
+
input: process.stdin,
|
|
58
|
+
output: process.stdout,
|
|
50
59
|
});
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const nxJsonPath = path.join(projectRoot, 'nx.json');
|
|
60
|
+
|
|
61
|
+
// Ask for AWS credentials with timeouts
|
|
62
|
+
const accessKeyId = await askWithTimeout(rl, 'AWS Access Key ID (press Enter to skip): ');
|
|
63
|
+
|
|
64
|
+
// If user skips, create basic config
|
|
65
|
+
if (!accessKeyId || accessKeyId === '') {
|
|
66
|
+
console.log('Skipping AWS configuration. Creating basic nx.json.');
|
|
67
|
+
// Check if nx.json exists and update or create
|
|
60
68
|
if (tree.exists(nxJsonPath)) {
|
|
61
69
|
updateJson(tree, nxJsonPath, (json) => {
|
|
62
|
-
// Preserve the existing configuration, just update the AWS credentials
|
|
63
70
|
if (!json.tasksRunnerOptions) {
|
|
64
|
-
json.tasksRunnerOptions =
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (!json.tasksRunnerOptions.default) {
|
|
68
|
-
json.tasksRunnerOptions.default = {
|
|
69
|
-
runner: '@nx-aws-plugin/nx-aws-cache',
|
|
70
|
-
options: {
|
|
71
|
-
runtimeCacheInputs: ['node --version']
|
|
72
|
-
}
|
|
73
|
-
};
|
|
71
|
+
json.tasksRunnerOptions = basicConfig.tasksRunnerOptions;
|
|
74
72
|
}
|
|
75
|
-
|
|
76
|
-
// Update only the AWS credentials
|
|
77
|
-
json.tasksRunnerOptions.default.options = {
|
|
78
|
-
...json.tasksRunnerOptions.default.options,
|
|
79
|
-
awsAccessKeyId,
|
|
80
|
-
awsSecretAccessKey,
|
|
81
|
-
awsRegion,
|
|
82
|
-
awsBucket
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
console.log('Updated nx.json with AWS configuration');
|
|
86
73
|
return json;
|
|
87
74
|
});
|
|
75
|
+
} else {
|
|
76
|
+
tree.write(nxJsonPath, JSON.stringify(basicConfig, null, 2));
|
|
88
77
|
}
|
|
89
78
|
} else {
|
|
90
|
-
|
|
79
|
+
// Get remaining AWS info
|
|
80
|
+
const secretAccessKey = await askWithTimeout(rl, 'AWS Secret Access Key: ');
|
|
81
|
+
const region = (await askWithTimeout(rl, 'AWS Region (default: us-east-1): ')) || 'us-east-1';
|
|
82
|
+
const bucketName = await askWithTimeout(rl, 'AWS S3 Bucket Name: ');
|
|
83
|
+
|
|
84
|
+
// Only add AWS config if all fields are provided
|
|
85
|
+
if (secretAccessKey && bucketName) {
|
|
86
|
+
// Use type assertion to avoid TypeScript errors
|
|
87
|
+
const awsConfig = { ...basicConfig };
|
|
88
|
+
// Use "as any" to bypass type checking
|
|
89
|
+
(awsConfig.tasksRunnerOptions.default.options as any) = {
|
|
90
|
+
...awsConfig.tasksRunnerOptions.default.options,
|
|
91
|
+
cacheDirectory: '.nx/cache',
|
|
92
|
+
remoteCache: {
|
|
93
|
+
s3: {
|
|
94
|
+
accessKeyId,
|
|
95
|
+
secretAccessKey,
|
|
96
|
+
region,
|
|
97
|
+
bucketName,
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// Update or create nx.json with AWS config
|
|
103
|
+
if (tree.exists(nxJsonPath)) {
|
|
104
|
+
updateJson(tree, nxJsonPath, () => awsConfig);
|
|
105
|
+
console.log('Updated nx.json with AWS configuration.');
|
|
106
|
+
} else {
|
|
107
|
+
tree.write(nxJsonPath, JSON.stringify(awsConfig, null, 2));
|
|
108
|
+
console.log('Created nx.json with AWS configuration.');
|
|
109
|
+
}
|
|
110
|
+
} else {
|
|
111
|
+
console.log('Incomplete AWS information. Creating basic nx.json.');
|
|
112
|
+
// Create basic config without AWS
|
|
113
|
+
if (tree.exists(nxJsonPath)) {
|
|
114
|
+
updateJson(tree, nxJsonPath, (json) => {
|
|
115
|
+
if (!json.tasksRunnerOptions) {
|
|
116
|
+
json.tasksRunnerOptions = basicConfig.tasksRunnerOptions;
|
|
117
|
+
}
|
|
118
|
+
return json;
|
|
119
|
+
});
|
|
120
|
+
} else {
|
|
121
|
+
tree.write(nxJsonPath, JSON.stringify(basicConfig, null, 2));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
91
124
|
}
|
|
92
125
|
} catch (error) {
|
|
93
126
|
console.error('Error setting up Nx configuration:', error);
|
|
127
|
+
// Fallback to basic config
|
|
128
|
+
if (tree.exists(nxJsonPath)) {
|
|
129
|
+
updateJson(tree, nxJsonPath, (json) => {
|
|
130
|
+
if (!json.tasksRunnerOptions) {
|
|
131
|
+
json.tasksRunnerOptions = basicConfig.tasksRunnerOptions;
|
|
132
|
+
}
|
|
133
|
+
return json;
|
|
134
|
+
});
|
|
135
|
+
} else {
|
|
136
|
+
tree.write(nxJsonPath, JSON.stringify(basicConfig, null, 2));
|
|
137
|
+
}
|
|
138
|
+
} finally {
|
|
139
|
+
// Ensure readline interface is closed
|
|
140
|
+
if (rl) {
|
|
141
|
+
rl.close();
|
|
142
|
+
}
|
|
143
|
+
console.log('Nx configuration setup complete.');
|
|
94
144
|
}
|
|
95
|
-
}
|
|
145
|
+
}
|