@nx/js 16.4.0-beta.1 → 16.4.0-beta.13
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/babel.js +3 -1
- package/executors.json +1 -0
- package/generators.json +12 -0
- package/migrations.json +12 -0
- package/package.json +6 -5
- package/plugins/jest/local-registry.d.ts +1 -0
- package/plugins/jest/local-registry.js +4 -0
- package/src/executors/node/node.impl.d.ts +1 -0
- package/src/executors/node/node.impl.js +59 -11
- package/src/executors/tsc/lib/batch/build-task-info-per-tsconfig-map.d.ts +5 -0
- package/src/executors/tsc/lib/batch/build-task-info-per-tsconfig-map.js +59 -0
- package/src/executors/tsc/lib/batch/index.d.ts +4 -0
- package/src/executors/tsc/lib/batch/index.js +7 -0
- package/src/executors/tsc/lib/batch/normalize-tasks-options.d.ts +3 -0
- package/src/executors/tsc/lib/batch/normalize-tasks-options.js +14 -0
- package/src/executors/tsc/lib/batch/types.d.ts +17 -0
- package/src/executors/tsc/lib/batch/types.js +2 -0
- package/src/executors/tsc/lib/batch/watch.d.ts +3 -0
- package/src/executors/tsc/lib/batch/watch.js +63 -0
- package/src/executors/tsc/lib/get-custom-transformers-factory.d.ts +3 -0
- package/src/executors/tsc/lib/get-custom-transformers-factory.js +13 -0
- package/src/executors/tsc/lib/get-task-options.d.ts +8 -0
- package/src/executors/tsc/lib/get-task-options.js +51 -0
- package/src/executors/tsc/lib/get-tsconfig.d.ts +4 -0
- package/src/executors/tsc/lib/get-tsconfig.js +138 -0
- package/src/executors/tsc/lib/index.d.ts +4 -0
- package/src/executors/tsc/lib/index.js +7 -0
- package/src/executors/tsc/lib/normalize-options.d.ts +2 -0
- package/src/executors/tsc/lib/normalize-options.js +32 -0
- package/src/executors/tsc/lib/typescript-compilation.d.ts +29 -0
- package/src/executors/tsc/lib/typescript-compilation.js +206 -0
- package/src/executors/tsc/lib/typescript-diagnostic-reporters.d.ts +3 -0
- package/src/executors/tsc/lib/typescript-diagnostic-reporters.js +37 -0
- package/src/executors/tsc/tsc.batch-impl.d.ts +5 -0
- package/src/executors/tsc/tsc.batch-impl.js +137 -0
- package/src/executors/tsc/tsc.impl.d.ts +0 -1
- package/src/executors/tsc/tsc.impl.js +4 -39
- package/src/executors/verdaccio/verdaccio.impl.d.ts +1 -0
- package/src/executors/verdaccio/verdaccio.impl.js +93 -45
- package/src/generators/library/library.js +2 -10
- package/src/generators/library/schema.json +7 -6
- package/src/generators/setup-build/generator.d.ts +5 -0
- package/src/generators/setup-build/generator.js +133 -0
- package/src/generators/setup-build/schema.d.ts +7 -0
- package/src/generators/setup-build/schema.json +42 -0
- package/src/generators/setup-verdaccio/files/config.yml +5 -6
- package/src/generators/setup-verdaccio/generator.js +5 -1
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/plugins/jest/start-local-registry.d.ts +12 -0
- package/src/plugins/jest/start-local-registry.js +61 -0
- package/src/utils/add-babel-inputs.d.ts +1 -0
- package/src/utils/add-babel-inputs.js +2 -0
- package/src/utils/add-local-registry-scripts.d.ts +5 -0
- package/src/utils/add-local-registry-scripts.js +57 -0
- package/src/utils/assets/copy-assets-handler.d.ts +5 -1
- package/src/utils/assets/copy-assets-handler.js +34 -23
- package/src/utils/compiler-helper-dependency.d.ts +2 -1
- package/src/utils/compiler-helper-dependency.js +13 -2
- package/src/utils/inline.d.ts +1 -1
- package/src/utils/inline.js +3 -3
- package/src/utils/minimal-publish-script.js +2 -5
- package/src/utils/schema.d.ts +3 -2
- package/src/utils/swc/add-swc-config.d.ts +1 -1
- package/src/utils/versions.d.ts +1 -1
- package/src/utils/versions.js +1 -1
- package/src/generators/setup-verdaccio/files/htpasswd +0 -1
|
@@ -1,51 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.tscExecutor = exports.createTypeScriptCompilationOptions =
|
|
3
|
+
exports.tscExecutor = exports.createTypeScriptCompilationOptions = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const assets_1 = require("../../utils/assets/assets");
|
|
6
|
-
const path_1 = require("path");
|
|
7
5
|
const copy_assets_handler_1 = require("../../utils/assets/copy-assets-handler");
|
|
8
6
|
const check_dependencies_1 = require("../../utils/check-dependencies");
|
|
9
7
|
const compiler_helper_dependency_1 = require("../../utils/compiler-helper-dependency");
|
|
10
8
|
const inline_1 = require("../../utils/inline");
|
|
11
9
|
const update_package_json_1 = require("../../utils/package-json/update-package-json");
|
|
12
10
|
const compile_typescript_files_1 = require("../../utils/typescript/compile-typescript-files");
|
|
13
|
-
const load_ts_transformers_1 = require("../../utils/typescript/load-ts-transformers");
|
|
14
11
|
const watch_for_single_file_changes_1 = require("../../utils/watch-for-single-file-changes");
|
|
15
|
-
|
|
16
|
-
const outputPath = (0, path_1.join)(contextRoot, options.outputPath);
|
|
17
|
-
const rootDir = options.rootDir
|
|
18
|
-
? (0, path_1.join)(contextRoot, options.rootDir)
|
|
19
|
-
: projectRoot;
|
|
20
|
-
if (options.watch == null) {
|
|
21
|
-
options.watch = false;
|
|
22
|
-
}
|
|
23
|
-
// TODO: put back when inlining story is more stable
|
|
24
|
-
// if (options.external == null) {
|
|
25
|
-
// options.external = 'all';
|
|
26
|
-
// } else if (Array.isArray(options.external) && options.external.length === 0) {
|
|
27
|
-
// options.external = 'none';
|
|
28
|
-
// }
|
|
29
|
-
if (Array.isArray(options.external) && options.external.length > 0) {
|
|
30
|
-
const firstItem = options.external[0];
|
|
31
|
-
if (firstItem === 'all' || firstItem === 'none') {
|
|
32
|
-
options.external = firstItem;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
const files = (0, assets_1.assetGlobsToFiles)(options.assets, contextRoot, outputPath);
|
|
36
|
-
return Object.assign(Object.assign({}, options), { root: contextRoot, sourceRoot,
|
|
37
|
-
projectRoot,
|
|
38
|
-
files,
|
|
39
|
-
outputPath, tsConfig: (0, path_1.join)(contextRoot, options.tsConfig), rootDir, mainOutputPath: (0, path_1.resolve)(outputPath, options.main.replace(`${projectRoot}/`, '').replace('.ts', '.js')) });
|
|
40
|
-
}
|
|
41
|
-
exports.normalizeOptions = normalizeOptions;
|
|
12
|
+
const lib_1 = require("./lib");
|
|
42
13
|
function createTypeScriptCompilationOptions(normalizedOptions, context) {
|
|
43
|
-
const { compilerPluginHooks } = (0, load_ts_transformers_1.loadTsTransformers)(normalizedOptions.transformers);
|
|
44
|
-
const getCustomTransformers = (program) => ({
|
|
45
|
-
before: compilerPluginHooks.beforeHooks.map((hook) => hook(program)),
|
|
46
|
-
after: compilerPluginHooks.afterHooks.map((hook) => hook(program)),
|
|
47
|
-
afterDeclarations: compilerPluginHooks.afterDeclarationsHooks.map((hook) => hook(program)),
|
|
48
|
-
});
|
|
49
14
|
return {
|
|
50
15
|
outputPath: normalizedOptions.outputPath,
|
|
51
16
|
projectName: context.projectName,
|
|
@@ -54,14 +19,14 @@ function createTypeScriptCompilationOptions(normalizedOptions, context) {
|
|
|
54
19
|
tsConfig: normalizedOptions.tsConfig,
|
|
55
20
|
watch: normalizedOptions.watch,
|
|
56
21
|
deleteOutputPath: normalizedOptions.clean,
|
|
57
|
-
getCustomTransformers,
|
|
22
|
+
getCustomTransformers: (0, lib_1.getCustomTrasformersFactory)(normalizedOptions.transformers),
|
|
58
23
|
};
|
|
59
24
|
}
|
|
60
25
|
exports.createTypeScriptCompilationOptions = createTypeScriptCompilationOptions;
|
|
61
26
|
function tscExecutor(_options, context) {
|
|
62
27
|
return tslib_1.__asyncGenerator(this, arguments, function* tscExecutor_1() {
|
|
63
28
|
const { sourceRoot, root } = context.projectsConfigurations.projects[context.projectName];
|
|
64
|
-
const options = normalizeOptions(_options, context.root, sourceRoot, root);
|
|
29
|
+
const options = (0, lib_1.normalizeOptions)(_options, context.root, sourceRoot, root);
|
|
65
30
|
const { projectRoot, tmpTsConfig, target, dependencies } = (0, check_dependencies_1.checkDependencies)(context, _options.tsConfig);
|
|
66
31
|
if (tmpTsConfig) {
|
|
67
32
|
options.tsConfig = tmpTsConfig;
|
|
@@ -5,6 +5,9 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const fs_extra_1 = require("fs-extra");
|
|
7
7
|
const child_process_1 = require("child_process");
|
|
8
|
+
const detectPort = require("detect-port");
|
|
9
|
+
const path_1 = require("path");
|
|
10
|
+
const semver_1 = require("semver");
|
|
8
11
|
let childProcess;
|
|
9
12
|
/**
|
|
10
13
|
* - set npm and yarn to use local registry
|
|
@@ -19,8 +22,17 @@ function verdaccioExecutor(options, context) {
|
|
|
19
22
|
catch (e) {
|
|
20
23
|
throw new Error('Verdaccio is not installed. Please run `npm install verdaccio` or `yarn add verdaccio`');
|
|
21
24
|
}
|
|
22
|
-
if (options.
|
|
23
|
-
(0,
|
|
25
|
+
if (options.storage) {
|
|
26
|
+
options.storage = (0, path_1.resolve)(context.root, options.storage);
|
|
27
|
+
if (options.clear && (0, fs_extra_1.existsSync)(options.storage)) {
|
|
28
|
+
(0, fs_extra_1.rmSync)(options.storage, { recursive: true, force: true });
|
|
29
|
+
console.log(`Cleared local registry storage folder ${options.storage}`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const port = yield detectPort(options.port);
|
|
33
|
+
if (port !== options.port) {
|
|
34
|
+
devkit_1.logger.info(`Port ${options.port} was occupied. Using port ${port}.`);
|
|
35
|
+
options.port = port;
|
|
24
36
|
}
|
|
25
37
|
const cleanupFunctions = options.location === 'none' ? [] : [setupNpm(options), setupYarn(options)];
|
|
26
38
|
const processExitListener = (signal) => {
|
|
@@ -36,16 +48,18 @@ function verdaccioExecutor(options, context) {
|
|
|
36
48
|
process.on('SIGINT', processExitListener);
|
|
37
49
|
process.on('SIGHUP', processExitListener);
|
|
38
50
|
try {
|
|
39
|
-
yield startVerdaccio(options);
|
|
51
|
+
yield startVerdaccio(options, context.root);
|
|
40
52
|
}
|
|
41
53
|
catch (e) {
|
|
42
|
-
devkit_1.logger.error('Failed to start verdaccio: ' + e.toString());
|
|
54
|
+
devkit_1.logger.error('Failed to start verdaccio: ' + (e === null || e === void 0 ? void 0 : e.toString()));
|
|
43
55
|
return {
|
|
44
56
|
success: false,
|
|
57
|
+
port: options.port,
|
|
45
58
|
};
|
|
46
59
|
}
|
|
47
60
|
return {
|
|
48
61
|
success: true,
|
|
62
|
+
port: options.port,
|
|
49
63
|
};
|
|
50
64
|
});
|
|
51
65
|
}
|
|
@@ -53,23 +67,13 @@ exports.verdaccioExecutor = verdaccioExecutor;
|
|
|
53
67
|
/**
|
|
54
68
|
* Fork the verdaccio process: https://verdaccio.org/docs/verdaccio-programmatically/#using-fork-from-child_process-module
|
|
55
69
|
*/
|
|
56
|
-
function startVerdaccio(options) {
|
|
70
|
+
function startVerdaccio(options, workspaceRoot) {
|
|
57
71
|
return new Promise((resolve, reject) => {
|
|
58
|
-
childProcess = (0, child_process_1.fork)(require.resolve('verdaccio/bin/verdaccio'), createVerdaccioOptions(options), {
|
|
59
|
-
env: Object.assign(Object.assign({}, process.env), { VERDACCIO_HANDLE_KILL_SIGNALS: 'true' }),
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
process.stdout.write(data);
|
|
64
|
-
});
|
|
65
|
-
childProcess.stderr.on('data', (data) => {
|
|
66
|
-
if (data.includes('VerdaccioWarning') ||
|
|
67
|
-
data.includes('DeprecationWarning')) {
|
|
68
|
-
process.stdout.write(data);
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
reject(data);
|
|
72
|
-
}
|
|
72
|
+
childProcess = (0, child_process_1.fork)(require.resolve('verdaccio/bin/verdaccio'), createVerdaccioOptions(options, workspaceRoot), {
|
|
73
|
+
env: Object.assign(Object.assign(Object.assign({}, process.env), { VERDACCIO_HANDLE_KILL_SIGNALS: 'true' }), (options.storage
|
|
74
|
+
? { VERDACCIO_STORAGE_PATH: options.storage }
|
|
75
|
+
: {})),
|
|
76
|
+
stdio: 'inherit',
|
|
73
77
|
});
|
|
74
78
|
childProcess.on('error', (err) => {
|
|
75
79
|
reject(err);
|
|
@@ -87,13 +91,13 @@ function startVerdaccio(options) {
|
|
|
87
91
|
});
|
|
88
92
|
});
|
|
89
93
|
}
|
|
90
|
-
function createVerdaccioOptions(options) {
|
|
94
|
+
function createVerdaccioOptions(options, workspaceRoot) {
|
|
91
95
|
const verdaccioArgs = [];
|
|
92
96
|
if (options.port) {
|
|
93
97
|
verdaccioArgs.push('--listen', options.port.toString());
|
|
94
98
|
}
|
|
95
99
|
if (options.config) {
|
|
96
|
-
verdaccioArgs.push('--config', options.config);
|
|
100
|
+
verdaccioArgs.push('--config', (0, path_1.join)(workspaceRoot, options.config));
|
|
97
101
|
}
|
|
98
102
|
return verdaccioArgs;
|
|
99
103
|
}
|
|
@@ -131,36 +135,80 @@ function setupNpm(options) {
|
|
|
131
135
|
}
|
|
132
136
|
};
|
|
133
137
|
}
|
|
138
|
+
function getYarnUnsafeHttpWhitelist(isYarnV1, options) {
|
|
139
|
+
return isYarnV1
|
|
140
|
+
? new Set(JSON.parse((0, child_process_1.execSync)(`yarn config get unsafeHttpWhitelist --json` + options.location ===
|
|
141
|
+
'home'
|
|
142
|
+
? ' --home'
|
|
143
|
+
: '').toString()))
|
|
144
|
+
: null;
|
|
145
|
+
}
|
|
146
|
+
function setYarnUnsafeHttpWhitelist(currentWhitelist, options) {
|
|
147
|
+
(0, child_process_1.execSync)(`yarn config set unsafeHttpWhitelist --json '${JSON.stringify(Array.from(currentWhitelist))}'` +
|
|
148
|
+
options.location ===
|
|
149
|
+
'home'
|
|
150
|
+
? ' --home'
|
|
151
|
+
: '');
|
|
152
|
+
}
|
|
134
153
|
function setupYarn(options) {
|
|
135
154
|
var _a, _b, _c;
|
|
136
155
|
try {
|
|
137
|
-
(0, child_process_1.execSync)('yarn --version');
|
|
138
|
-
}
|
|
139
|
-
catch (e) {
|
|
140
|
-
return () => { };
|
|
141
|
-
}
|
|
142
|
-
let yarnRegistryPath;
|
|
143
|
-
try {
|
|
144
|
-
yarnRegistryPath = (_c = (_b = (_a = (0, child_process_1.execSync)(`yarn config get registry`)) === null || _a === void 0 ? void 0 : _a.toString()) === null || _b === void 0 ? void 0 : _b.trim()) === null || _c === void 0 ? void 0 : _c.replace('\u001b[2K\u001b[1G', ''); // strip out ansi codes
|
|
145
|
-
(0, child_process_1.execSync)(`yarn config set registry http://localhost:${options.port}/`);
|
|
146
|
-
devkit_1.logger.info(`Set yarn registry to http://localhost:${options.port}/`);
|
|
147
|
-
}
|
|
148
|
-
catch (e) {
|
|
149
|
-
throw new Error(`Failed to set yarn registry to http://localhost:${options.port}/: ${e.message}`);
|
|
150
|
-
}
|
|
151
|
-
return () => {
|
|
156
|
+
const isYarnV1 = (0, semver_1.major)((0, child_process_1.execSync)('yarn --version').toString().trim()) === 1;
|
|
152
157
|
try {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
158
|
+
const registryConfigName = isYarnV1 ? 'registry' : 'npmRegistryServer';
|
|
159
|
+
const yarnRegistryPath = (_c = (_b = (_a = (0, child_process_1.execSync)(`yarn config get ${registryConfigName}`)) === null || _a === void 0 ? void 0 : _a.toString()) === null || _b === void 0 ? void 0 : _b.trim()) === null || _c === void 0 ? void 0 : _c.replace('\u001b[2K\u001b[1G', ''); // strip out ansi codes
|
|
160
|
+
(0, child_process_1.execSync)(`yarn config set ${registryConfigName} http://localhost:${options.port}/` +
|
|
161
|
+
options.location ===
|
|
162
|
+
'home'
|
|
163
|
+
? ' --home'
|
|
164
|
+
: '');
|
|
165
|
+
devkit_1.logger.info(`Set yarn registry to http://localhost:${options.port}/`);
|
|
166
|
+
const currentWhitelist = getYarnUnsafeHttpWhitelist(isYarnV1, options);
|
|
167
|
+
let whitelistedLocalhost = false;
|
|
168
|
+
if (!isYarnV1) {
|
|
169
|
+
if (!currentWhitelist.has('localhost')) {
|
|
170
|
+
whitelistedLocalhost = true;
|
|
171
|
+
currentWhitelist.add('localhost');
|
|
172
|
+
setYarnUnsafeHttpWhitelist(currentWhitelist, options);
|
|
173
|
+
devkit_1.logger.info(`Whitelisted http://localhost:${options.port}/ as an unsafe http server`);
|
|
174
|
+
}
|
|
159
175
|
}
|
|
176
|
+
return () => {
|
|
177
|
+
try {
|
|
178
|
+
if (yarnRegistryPath) {
|
|
179
|
+
(0, child_process_1.execSync)(`yarn config set ${registryConfigName} ${yarnRegistryPath}` +
|
|
180
|
+
options.location ===
|
|
181
|
+
'home'
|
|
182
|
+
? ' --home'
|
|
183
|
+
: '');
|
|
184
|
+
devkit_1.logger.info(`Reset yarn ${registryConfigName} to ${yarnRegistryPath}`);
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
(0, child_process_1.execSync)(`yarn config delete ${registryConfigName}` + options.location ===
|
|
188
|
+
'home'
|
|
189
|
+
? ' --home'
|
|
190
|
+
: '');
|
|
191
|
+
}
|
|
192
|
+
if (whitelistedLocalhost) {
|
|
193
|
+
const currentWhitelist = getYarnUnsafeHttpWhitelist(isYarnV1, options);
|
|
194
|
+
if (currentWhitelist.has('localhost')) {
|
|
195
|
+
currentWhitelist.delete('localhost');
|
|
196
|
+
setYarnUnsafeHttpWhitelist(currentWhitelist, options);
|
|
197
|
+
devkit_1.logger.info(`Removed http://localhost:${options.port}/ as an unsafe http server`);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
catch (e) {
|
|
202
|
+
throw new Error(`Failed to reset yarn registry: ${e.message}`);
|
|
203
|
+
}
|
|
204
|
+
};
|
|
160
205
|
}
|
|
161
206
|
catch (e) {
|
|
162
|
-
throw new Error(`Failed to
|
|
207
|
+
throw new Error(`Failed to set yarn registry to http://localhost:${options.port}/: ${e.message}`);
|
|
163
208
|
}
|
|
164
|
-
}
|
|
209
|
+
}
|
|
210
|
+
catch (e) {
|
|
211
|
+
return () => { };
|
|
212
|
+
}
|
|
165
213
|
}
|
|
166
214
|
exports.default = verdaccioExecutor;
|
|
@@ -44,12 +44,10 @@ function projectGenerator(tree, schema, destinationDir, filesDir) {
|
|
|
44
44
|
includeVitest: options.unitTestRunner === 'vitest',
|
|
45
45
|
includeLib: true,
|
|
46
46
|
skipFormat: true,
|
|
47
|
+
testEnvironment: options.testEnvironment,
|
|
47
48
|
});
|
|
48
49
|
tasks.push(viteTask);
|
|
49
50
|
}
|
|
50
|
-
if (options.bundler === 'rollup') {
|
|
51
|
-
ensureBabelRootConfigExists(tree);
|
|
52
|
-
}
|
|
53
51
|
if (options.linter !== 'none') {
|
|
54
52
|
const lintCallback = yield addLint(tree, options);
|
|
55
53
|
tasks.push(lintCallback);
|
|
@@ -70,6 +68,7 @@ function projectGenerator(tree, schema, destinationDir, filesDir) {
|
|
|
70
68
|
uiFramework: 'none',
|
|
71
69
|
coverageProvider: 'c8',
|
|
72
70
|
skipFormat: true,
|
|
71
|
+
testEnvironment: options.testEnvironment,
|
|
73
72
|
});
|
|
74
73
|
tasks.push(vitestTask);
|
|
75
74
|
}
|
|
@@ -384,13 +383,6 @@ function getBuildExecutor(bundler) {
|
|
|
384
383
|
return undefined;
|
|
385
384
|
}
|
|
386
385
|
}
|
|
387
|
-
function ensureBabelRootConfigExists(tree) {
|
|
388
|
-
if (tree.exists('babel.config.json'))
|
|
389
|
-
return;
|
|
390
|
-
(0, devkit_1.writeJson)(tree, 'babel.config.json', {
|
|
391
|
-
babelrcRoots: ['*'],
|
|
392
|
-
});
|
|
393
|
-
}
|
|
394
386
|
function getOutputPath(options, destinationDir) {
|
|
395
387
|
const parts = ['dist'];
|
|
396
388
|
if (destinationDir) {
|
|
@@ -56,12 +56,8 @@
|
|
|
56
56
|
"testEnvironment": {
|
|
57
57
|
"type": "string",
|
|
58
58
|
"enum": ["jsdom", "node"],
|
|
59
|
-
"description": "The test environment to use if unitTestRunner is set to jest.",
|
|
60
|
-
"default": "
|
|
61
|
-
},
|
|
62
|
-
"importPath": {
|
|
63
|
-
"type": "string",
|
|
64
|
-
"description": "The library name used to import it, like @myorg/my-awesome-lib."
|
|
59
|
+
"description": "The test environment to use if unitTestRunner is set to jest or vitest.",
|
|
60
|
+
"default": "node"
|
|
65
61
|
},
|
|
66
62
|
"pascalCaseFiles": {
|
|
67
63
|
"type": "boolean",
|
|
@@ -85,6 +81,11 @@
|
|
|
85
81
|
"description": "Generate a publishable library.",
|
|
86
82
|
"x-priority": "important"
|
|
87
83
|
},
|
|
84
|
+
"importPath": {
|
|
85
|
+
"type": "string",
|
|
86
|
+
"description": "The library name used to import it, like @myorg/my-awesome-lib. Required for publishable library.",
|
|
87
|
+
"x-priority": "important"
|
|
88
|
+
},
|
|
88
89
|
"buildable": {
|
|
89
90
|
"type": "boolean",
|
|
90
91
|
"default": true,
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type GeneratorCallback, type Tree } from '@nx/devkit';
|
|
2
|
+
import { SetupBuildGeneratorSchema } from './schema';
|
|
3
|
+
export declare function setupBuildGenerator(tree: Tree, options: SetupBuildGeneratorSchema): Promise<GeneratorCallback>;
|
|
4
|
+
export default setupBuildGenerator;
|
|
5
|
+
export declare const setupBuildSchematic: (generatorOptions: SetupBuildGeneratorSchema) => (tree: any, context: any) => Promise<any>;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setupBuildSchematic = exports.setupBuildGenerator = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const add_swc_config_1 = require("../../utils/swc/add-swc-config");
|
|
7
|
+
const add_swc_dependencies_1 = require("../../utils/swc/add-swc-dependencies");
|
|
8
|
+
const versions_1 = require("../../utils/versions");
|
|
9
|
+
function setupBuildGenerator(tree, options) {
|
|
10
|
+
var _a, _b, _c;
|
|
11
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
12
|
+
const tasks = [];
|
|
13
|
+
const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
14
|
+
const buildTarget = (_a = options.buildTarget) !== null && _a !== void 0 ? _a : 'build';
|
|
15
|
+
(_b = project.targets) !== null && _b !== void 0 ? _b : (project.targets = {});
|
|
16
|
+
let mainFile;
|
|
17
|
+
if (options.main) {
|
|
18
|
+
mainFile = options.main;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
const root = (_c = project.sourceRoot) !== null && _c !== void 0 ? _c : project.root;
|
|
22
|
+
for (const f of [
|
|
23
|
+
(0, devkit_1.joinPathFragments)(root, 'main.ts'),
|
|
24
|
+
(0, devkit_1.joinPathFragments)(root, 'main.js'),
|
|
25
|
+
(0, devkit_1.joinPathFragments)(root, 'index.ts'),
|
|
26
|
+
(0, devkit_1.joinPathFragments)(root, 'index.js'),
|
|
27
|
+
]) {
|
|
28
|
+
if (tree.exists(f)) {
|
|
29
|
+
mainFile = f;
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (!mainFile || !tree.exists(mainFile)) {
|
|
35
|
+
throw new Error(`Cannot locate a main file for ${options.project}. Please specify one using --main=<file-path>.`);
|
|
36
|
+
}
|
|
37
|
+
let tsConfigFile;
|
|
38
|
+
if (options.tsConfig) {
|
|
39
|
+
tsConfigFile = options.tsConfig;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
for (const f of [
|
|
43
|
+
'tsconfig.lib.json',
|
|
44
|
+
'tsconfig.app.json',
|
|
45
|
+
'tsconfig.json',
|
|
46
|
+
]) {
|
|
47
|
+
const candidate = (0, devkit_1.joinPathFragments)(project.root, f);
|
|
48
|
+
if (tree.exists(candidate)) {
|
|
49
|
+
tsConfigFile = candidate;
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (!tsConfigFile || !tree.exists(tsConfigFile)) {
|
|
55
|
+
throw new Error(`Cannot locate a tsConfig file for ${options.project}. Please specify one using --tsConfig=<file-path>.`);
|
|
56
|
+
}
|
|
57
|
+
switch (options.bundler) {
|
|
58
|
+
case 'vite': {
|
|
59
|
+
const { viteConfigurationGenerator } = (0, devkit_1.ensurePackage)('@nx/vite', versions_1.nxVersion);
|
|
60
|
+
const task = yield viteConfigurationGenerator(tree, {
|
|
61
|
+
buildTarget: options.buildTarget,
|
|
62
|
+
project: options.project,
|
|
63
|
+
newProject: true,
|
|
64
|
+
uiFramework: 'none',
|
|
65
|
+
includeVitest: false,
|
|
66
|
+
includeLib: true,
|
|
67
|
+
skipFormat: true,
|
|
68
|
+
});
|
|
69
|
+
tasks.push(task);
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
case 'esbuild': {
|
|
73
|
+
const { esbuildProjectGenerator } = (0, devkit_1.ensurePackage)('@nx/esbuild', versions_1.nxVersion);
|
|
74
|
+
const task = yield esbuildProjectGenerator(tree, {
|
|
75
|
+
main: mainFile,
|
|
76
|
+
buildTarget: options.buildTarget,
|
|
77
|
+
project: options.project,
|
|
78
|
+
skipFormat: true,
|
|
79
|
+
});
|
|
80
|
+
tasks.push(task);
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
case 'rollup': {
|
|
84
|
+
const { rollupProjectGenerator } = (0, devkit_1.ensurePackage)('@nx/rollup', versions_1.nxVersion);
|
|
85
|
+
const task = yield rollupProjectGenerator(tree, {
|
|
86
|
+
buildTarget: options.buildTarget,
|
|
87
|
+
main: mainFile,
|
|
88
|
+
project: options.project,
|
|
89
|
+
skipFormat: true,
|
|
90
|
+
compiler: 'tsc',
|
|
91
|
+
});
|
|
92
|
+
tasks.push(task);
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
case 'tsc': {
|
|
96
|
+
const outputPath = (0, devkit_1.joinPathFragments)('dist', project.root);
|
|
97
|
+
project.targets[buildTarget] = {
|
|
98
|
+
executor: `@nx/js:tsc`,
|
|
99
|
+
outputs: ['{options.outputPath}'],
|
|
100
|
+
options: {
|
|
101
|
+
outputPath,
|
|
102
|
+
main: mainFile,
|
|
103
|
+
tsConfig: tsConfigFile,
|
|
104
|
+
assets: [],
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
(0, devkit_1.updateProjectConfiguration)(tree, options.project, project);
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
case 'swc': {
|
|
111
|
+
const outputPath = (0, devkit_1.joinPathFragments)('dist', project.root);
|
|
112
|
+
project.targets[buildTarget] = {
|
|
113
|
+
executor: `@nx/js:swc`,
|
|
114
|
+
outputs: ['{options.outputPath}'],
|
|
115
|
+
options: {
|
|
116
|
+
outputPath,
|
|
117
|
+
main: mainFile,
|
|
118
|
+
tsConfig: tsConfigFile,
|
|
119
|
+
assets: [],
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
(0, devkit_1.updateProjectConfiguration)(tree, options.project, project);
|
|
123
|
+
(0, add_swc_dependencies_1.addSwcDependencies)(tree);
|
|
124
|
+
(0, add_swc_config_1.addSwcConfig)(tree, project.root, 'es6');
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
yield (0, devkit_1.formatFiles)(tree);
|
|
128
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
exports.setupBuildGenerator = setupBuildGenerator;
|
|
132
|
+
exports.default = setupBuildGenerator;
|
|
133
|
+
exports.setupBuildSchematic = (0, devkit_1.convertNxGenerator)(setupBuildGenerator);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "SetupBuild",
|
|
4
|
+
"title": "Setup Build",
|
|
5
|
+
"description": "Sets up build target for a project.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"project": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "Project to add the build target to.",
|
|
11
|
+
"$default": {
|
|
12
|
+
"$source": "argv",
|
|
13
|
+
"index": 0
|
|
14
|
+
},
|
|
15
|
+
"x-prompt": "Which project do you want to add build to?",
|
|
16
|
+
"x-dropdown": "projects",
|
|
17
|
+
"x-priority": "important"
|
|
18
|
+
},
|
|
19
|
+
"bundler": {
|
|
20
|
+
"description": "The bundler to use to build the project.",
|
|
21
|
+
"type": "string",
|
|
22
|
+
"enum": ["tsc", "swc", "rollup", "vite", "esbuild"],
|
|
23
|
+
"default": "tsc",
|
|
24
|
+
"x-prompt": "Which bundler would you like to use to build the project?",
|
|
25
|
+
"x-priority": "important"
|
|
26
|
+
},
|
|
27
|
+
"main": {
|
|
28
|
+
"description": "The path to the main entry file, relative to workspace root. Defaults to <project>/src/index.ts or <project>/src/main.ts.",
|
|
29
|
+
"type": "string"
|
|
30
|
+
},
|
|
31
|
+
"tsConfig": {
|
|
32
|
+
"description": "The path to the tsConfig file, relative to workspace root. Defaults to <project>/tsconfig.lib.json or <project>/tsconfig.app.json depending on project type.",
|
|
33
|
+
"type": "string"
|
|
34
|
+
},
|
|
35
|
+
"buildTarget": {
|
|
36
|
+
"description": "The build target to add.",
|
|
37
|
+
"type": "string",
|
|
38
|
+
"default": "build"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"required": ["project", "bundler"]
|
|
42
|
+
}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
# path to a directory with all packages
|
|
2
2
|
storage: ../tmp/local-registry/storage
|
|
3
3
|
|
|
4
|
-
auth:
|
|
5
|
-
htpasswd:
|
|
6
|
-
file: ./htpasswd
|
|
7
|
-
|
|
8
4
|
# a list of other known repositories we can talk to
|
|
9
5
|
uplinks:
|
|
10
6
|
npmjs:
|
|
11
|
-
url:
|
|
7
|
+
url: <%= npmUplinkRegistry %>
|
|
12
8
|
maxage: 60m
|
|
13
9
|
|
|
14
10
|
packages:
|
|
@@ -26,4 +22,7 @@ packages:
|
|
|
26
22
|
logs:
|
|
27
23
|
type: stdout
|
|
28
24
|
format: pretty
|
|
29
|
-
level:
|
|
25
|
+
level: warn
|
|
26
|
+
|
|
27
|
+
publish:
|
|
28
|
+
allow_offline: true # set offline to true to allow publish offline
|
|
@@ -5,10 +5,14 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const path = require("path");
|
|
7
7
|
const versions_1 = require("../../utils/versions");
|
|
8
|
+
const child_process_1 = require("child_process");
|
|
8
9
|
function setupVerdaccio(tree, options) {
|
|
10
|
+
var _a, _b, _c;
|
|
9
11
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
10
12
|
if (!tree.exists('.verdaccio/config.yml')) {
|
|
11
|
-
(0, devkit_1.generateFiles)(tree, path.join(__dirname, 'files'), '.verdaccio', {
|
|
13
|
+
(0, devkit_1.generateFiles)(tree, path.join(__dirname, 'files'), '.verdaccio', {
|
|
14
|
+
npmUplinkRegistry: (_c = (_b = (_a = (0, child_process_1.execSync)('npm config get registry')) === null || _a === void 0 ? void 0 : _a.toString()) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : 'https://registry.npmjs.org',
|
|
15
|
+
});
|
|
12
16
|
}
|
|
13
17
|
const verdaccioTarget = {
|
|
14
18
|
executor: '@nx/js:verdaccio',
|
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createPackageJson = exports.getLockFileName = exports.createLockFile = exports.initGenerator = exports.libraryGenerator = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
tslib_1.__exportStar(require("./utils/typescript/add-tslib-dependencies"), exports);
|
|
5
6
|
tslib_1.__exportStar(require("./utils/typescript/load-ts-transformers"), exports);
|
|
6
7
|
tslib_1.__exportStar(require("./utils/typescript/print-diagnostics"), exports);
|
|
7
8
|
tslib_1.__exportStar(require("./utils/typescript/run-type-check"), exports);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function is used to start a local registry for testing purposes.
|
|
3
|
+
* @param localRegistryTarget the target to run to start the local registry e.g. workspace:local-registry
|
|
4
|
+
* @param storage the storage location for the local registry
|
|
5
|
+
* @param verbose whether to log verbose output
|
|
6
|
+
*/
|
|
7
|
+
export declare function startLocalRegistry({ localRegistryTarget, storage, verbose, }: {
|
|
8
|
+
localRegistryTarget: string;
|
|
9
|
+
storage?: string;
|
|
10
|
+
verbose?: boolean;
|
|
11
|
+
}): Promise<() => void>;
|
|
12
|
+
export default startLocalRegistry;
|