@common-stack/generate-plugin 7.0.4-alpha.1 → 7.0.4-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 +4 -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-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-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
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [7.0.4-alpha.2](https://github.com/cdmbase/common-stack/compare/v7.0.4-alpha.1...v7.0.4-alpha.2) (2025-02-28)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @common-stack/generate-plugin
|
|
9
|
+
|
|
6
10
|
## [7.0.4-alpha.1](https://github.com/cdmbase/common-stack/compare/v7.0.4-alpha.0...v7.0.4-alpha.1) (2025-02-28)
|
|
7
11
|
|
|
8
12
|
**Note:** Version bump only for package @common-stack/generate-plugin
|
|
@@ -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.1",
|
|
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
|
|
|
@@ -1,28 +1,16 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
],
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
"include": [
|
|
18
|
-
"src"
|
|
19
|
-
],
|
|
20
|
-
"exclude": [
|
|
21
|
-
"../../../node_modules",
|
|
22
|
-
"node_modules",
|
|
23
|
-
"lib",
|
|
24
|
-
"lib",
|
|
25
|
-
"webpack.config.js",
|
|
26
|
-
"rollup.config.mjs"
|
|
27
|
-
]
|
|
28
|
-
}
|
|
2
|
+
"extends": "<%= offsetFromRoot %>tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "lib",
|
|
5
|
+
"rootDir": "./src",
|
|
6
|
+
"sourceMap": true,
|
|
7
|
+
"noImplicitAny": true,
|
|
8
|
+
"declaration": true,
|
|
9
|
+
"lib": ["es6", "dom", "esnext", "es2015.core"],
|
|
10
|
+
"allowSyntheticDefaultImports": true,
|
|
11
|
+
"esModuleInterop": true,
|
|
12
|
+
"jsx": "react"
|
|
13
|
+
},
|
|
14
|
+
"include": ["src"],
|
|
15
|
+
"exclude": ["node_modules", "lib"]
|
|
16
|
+
}
|
|
@@ -1,29 +1,34 @@
|
|
|
1
|
-
import { createRollupConfig } from '
|
|
1
|
+
import { createRollupConfig } from '<%= offsetFromRoot %>rollup.config.base.mjs';
|
|
2
2
|
|
|
3
3
|
// Define any additional plugins specific to this bundle
|
|
4
|
-
const additionalPlugins = [
|
|
5
|
-
];
|
|
4
|
+
const additionalPlugins = [];
|
|
6
5
|
|
|
7
6
|
// Use the createRollupConfig function to merge the base and specific configurations
|
|
8
|
-
export default
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
]
|
|
7
|
+
export default (commandLineArgs) => {
|
|
8
|
+
const isWatchMode = commandLineArgs.watch;
|
|
9
|
+
return [
|
|
10
|
+
createRollupConfig({
|
|
11
|
+
input: ['src/index.ts'],
|
|
12
|
+
plugins: [
|
|
13
|
+
// Spread in additional plugins specific to this config
|
|
14
|
+
...additionalPlugins,
|
|
15
|
+
],
|
|
16
|
+
output: [
|
|
17
|
+
{
|
|
18
|
+
dir: 'lib',
|
|
19
|
+
format: 'es',
|
|
20
|
+
name: 'Accounts',
|
|
21
|
+
compact: true,
|
|
22
|
+
exports: 'named',
|
|
23
|
+
sourcemap: true,
|
|
24
|
+
preserveModules: true,
|
|
25
|
+
chunkFileNames: '[name]-[hash].[format].js',
|
|
26
|
+
globals: { react: 'React' },
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
}, {
|
|
30
|
+
isWatchMode,
|
|
31
|
+
generateRoutesJSON: false,
|
|
32
|
+
}),
|
|
33
|
+
];
|
|
34
|
+
};
|
|
@@ -1,27 +1,14 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
]
|
|
14
|
-
|
|
15
|
-
},
|
|
16
|
-
"include": [
|
|
17
|
-
"src"
|
|
18
|
-
],
|
|
19
|
-
"exclude": [
|
|
20
|
-
"../../../node_modules",
|
|
21
|
-
"node_modules",
|
|
22
|
-
"lib",
|
|
23
|
-
"lib",
|
|
24
|
-
"webpack.config.js",
|
|
25
|
-
"rollup.config.mjs"
|
|
26
|
-
]
|
|
27
|
-
}
|
|
2
|
+
"extends": "<%= offsetFromRoot %>tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"jsx": "react",
|
|
5
|
+
"rootDir": "src",
|
|
6
|
+
"outDir": "lib",
|
|
7
|
+
"declaration": true,
|
|
8
|
+
"declarationDir": "lib",
|
|
9
|
+
"types": ["@types/node", "@types/jest", "../../../typings"],
|
|
10
|
+
"skipLibCheck": true
|
|
11
|
+
},
|
|
12
|
+
"include": ["src"],
|
|
13
|
+
"exclude": ["../../../node_modules", "node_modules", "lib", "webpack.config.js", "rollup.config.mjs"]
|
|
14
|
+
}
|
|
@@ -1,65 +1,37 @@
|
|
|
1
|
-
import
|
|
2
|
-
import image from '@rollup/plugin-image';
|
|
3
|
-
import typescript from '@rollup/plugin-typescript';
|
|
4
|
-
import { string } from 'rollup-plugin-string';
|
|
5
|
-
function appendJsExtensionForMonacoEditor() {
|
|
6
|
-
return {
|
|
7
|
-
name: 'append-js-extension-for-monaco-editor',
|
|
8
|
-
transform(code, id) {
|
|
9
|
-
// Only modify .ts files and ignore node_modules
|
|
10
|
-
if (id.includes('node_modules') || !id.endsWith('.ts')) {
|
|
11
|
-
return null;
|
|
12
|
-
}
|
|
1
|
+
import { createRollupConfig } from '<%= offsetFromRoot %>rollup.config.base.mjs';
|
|
13
2
|
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
// Define any additional plugins specific to this bundle
|
|
4
|
+
const additionalPlugins = [];
|
|
16
5
|
|
|
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
|
-
|
|
42
|
-
image(),
|
|
43
|
-
graphql({
|
|
44
|
-
include: '**/*.gql',
|
|
45
|
-
}),
|
|
46
|
-
string({
|
|
47
|
-
include: '**/*.graphql',
|
|
48
|
-
}),
|
|
49
|
-
appendJsExtensionForMonacoEditor(),
|
|
50
|
-
],
|
|
51
|
-
output: [
|
|
6
|
+
// Use the createRollupConfig function to merge the base and specific configurations
|
|
7
|
+
export default (commandLineArgs) => {
|
|
8
|
+
const isWatchMode = commandLineArgs.watch;
|
|
9
|
+
return [
|
|
10
|
+
createRollupConfig(
|
|
11
|
+
{
|
|
12
|
+
input: ['src/index.ts'],
|
|
13
|
+
plugins: [
|
|
14
|
+
// Spread in additional plugins specific to this config
|
|
15
|
+
...additionalPlugins,
|
|
16
|
+
],
|
|
17
|
+
output: [
|
|
18
|
+
{
|
|
19
|
+
dir: 'lib',
|
|
20
|
+
format: 'es',
|
|
21
|
+
name: 'Accounts',
|
|
22
|
+
compact: true,
|
|
23
|
+
exports: 'named',
|
|
24
|
+
sourcemap: true,
|
|
25
|
+
preserveModules: true,
|
|
26
|
+
chunkFileNames: '[name]-[hash].[format].js',
|
|
27
|
+
globals: { react: 'React' },
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
},
|
|
52
31
|
{
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
name: 'Core',
|
|
56
|
-
compact: true,
|
|
57
|
-
exports: 'named',
|
|
58
|
-
sourcemap: false,
|
|
59
|
-
preserveModules: true,
|
|
60
|
-
chunkFileNames: '[name]-[hash].[format].js',
|
|
61
|
-
globals,
|
|
32
|
+
isWatchMode,
|
|
33
|
+
generateRoutesJSON: false,
|
|
62
34
|
},
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
35
|
+
),
|
|
36
|
+
];
|
|
37
|
+
};
|
|
@@ -1,22 +1,13 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
"exclude": [
|
|
15
|
-
"../../../node_modules",
|
|
16
|
-
"node_modules",
|
|
17
|
-
"lib",
|
|
18
|
-
"lib",
|
|
19
|
-
"webpack.config.js",
|
|
20
|
-
"rollup.config.mjs"
|
|
21
|
-
]
|
|
22
|
-
}
|
|
2
|
+
"extends": "<%= offsetFromRoot %>tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"resolveJsonModule": true,
|
|
5
|
+
"rootDir": "src",
|
|
6
|
+
"outDir": "lib",
|
|
7
|
+
"declaration": true,
|
|
8
|
+
"preserveConstEnums": true,
|
|
9
|
+
"declarationDir": "lib"
|
|
10
|
+
},
|
|
11
|
+
"include": ["src"],
|
|
12
|
+
"exclude": ["../../../node_modules", "node_modules", "lib", "webpack.config.js", "rollup.config.mjs"]
|
|
13
|
+
}
|
|
@@ -1,30 +1,37 @@
|
|
|
1
|
-
import { createRollupConfig } from '
|
|
2
|
-
import json from '@rollup/plugin-json'
|
|
1
|
+
import { createRollupConfig } from '<%= offsetFromRoot %>rollup.config.base.mjs';
|
|
2
|
+
import json from '@rollup/plugin-json';
|
|
3
3
|
|
|
4
4
|
// Define any additional plugins specific to this bundle
|
|
5
|
-
const additionalPlugins = [
|
|
6
|
-
json()
|
|
7
|
-
];
|
|
5
|
+
const additionalPlugins = [json()];
|
|
8
6
|
|
|
9
7
|
// Use the createRollupConfig function to merge the base and specific configurations
|
|
10
|
-
export default
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
// Spread in additional plugins specific to this config
|
|
15
|
-
...additionalPlugins,
|
|
16
|
-
],
|
|
17
|
-
output: [
|
|
8
|
+
export default (commandLineArgs) => {
|
|
9
|
+
const isWatchMode = commandLineArgs.watch;
|
|
10
|
+
return [
|
|
11
|
+
createRollupConfig(
|
|
18
12
|
{
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
13
|
+
input: ['src/index.ts'],
|
|
14
|
+
plugins: [
|
|
15
|
+
// Spread in additional plugins specific to this config
|
|
16
|
+
...additionalPlugins,
|
|
17
|
+
],
|
|
18
|
+
output: [
|
|
19
|
+
{
|
|
20
|
+
dir: 'lib',
|
|
21
|
+
format: 'es',
|
|
22
|
+
name: 'Accounts',
|
|
23
|
+
compact: true,
|
|
24
|
+
exports: 'named',
|
|
25
|
+
sourcemap: true,
|
|
26
|
+
preserveModules: true,
|
|
27
|
+
chunkFileNames: '[name]-[hash].[format].js',
|
|
28
|
+
},
|
|
29
|
+
],
|
|
27
30
|
},
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
{
|
|
32
|
+
isWatchMode,
|
|
33
|
+
generateRoutesJSON: false,
|
|
34
|
+
},
|
|
35
|
+
),
|
|
36
|
+
];
|
|
37
|
+
};
|
|
@@ -1,27 +1,17 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
]
|
|
18
|
-
},
|
|
19
|
-
"include": ["src"],
|
|
20
|
-
"exclude": [
|
|
21
|
-
"node_modules",
|
|
22
|
-
"lib",
|
|
23
|
-
"dist",
|
|
24
|
-
"rollup.config.mjs",
|
|
25
|
-
"webpack.config.js"
|
|
26
|
-
]
|
|
2
|
+
"extends": "<%= offsetFromRoot %>tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"resolveJsonModule": true,
|
|
5
|
+
"rootDir": "./src",
|
|
6
|
+
"outDir": "lib",
|
|
7
|
+
"sourceMap": false,
|
|
8
|
+
"noEmitOnError": false,
|
|
9
|
+
"declarationDir": "lib",
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"declaration": true,
|
|
12
|
+
"declarationMap": true,
|
|
13
|
+
"types": ["@types/node", "@types/jest", "../../../typings"]
|
|
14
|
+
},
|
|
15
|
+
"include": ["src"],
|
|
16
|
+
"exclude": ["node_modules", "lib", "dist", "rollup.config.mjs", "webpack.config.js"]
|
|
27
17
|
}
|
|
@@ -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,OAAO;aACV;AACD,YAAA,eAAe,CAAC,IAAI,EAAO,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAA,OAAO,KAAE,IAAI,EAAE,WAAW,CAAC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AO,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;
|