nx 22.6.0 → 22.6.1
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/bin/nx.js +13 -8
- package/package.json +11 -12
- package/src/adapter/ngcli-adapter.d.ts +8 -5
- package/src/adapter/ngcli-adapter.d.ts.map +1 -1
- package/src/adapter/ngcli-adapter.js +29 -15
- package/src/ai/clone-ai-config-repo.d.ts.map +1 -1
- package/src/ai/clone-ai-config-repo.js +2 -0
- package/src/command-line/add/add.js +1 -1
- package/src/command-line/examples.d.ts +7 -0
- package/src/command-line/examples.d.ts.map +1 -1
- package/src/command-line/examples.js +29 -1
- package/src/command-line/exec/exec.js +3 -3
- package/src/command-line/format/format.js +3 -3
- package/src/command-line/generate/generate.d.ts.map +1 -1
- package/src/command-line/generate/generate.js +1 -1
- package/src/command-line/graph/graph.js +1 -1
- package/src/command-line/init/command-object.js +1 -21
- package/src/command-line/init/configure-plugins.js +1 -1
- package/src/command-line/init/implementation/angular/integrated-workspace.js +1 -1
- package/src/command-line/init/implementation/angular/legacy-angular-versions.js +2 -2
- package/src/command-line/init/implementation/deduce-default-base.js +5 -5
- package/src/command-line/init/implementation/dot-nx/add-nx-scripts.js +2 -2
- package/src/command-line/init/implementation/dot-nx/nxw.js +1 -1
- package/src/command-line/init/implementation/utils.d.ts +1 -2
- package/src/command-line/init/implementation/utils.d.ts.map +1 -1
- package/src/command-line/init/implementation/utils.js +1 -15
- package/src/command-line/init/init-v1.d.ts +0 -3
- package/src/command-line/init/init-v1.d.ts.map +1 -1
- package/src/command-line/init/init-v1.js +1 -27
- package/src/command-line/init/init-v2.d.ts +0 -1
- package/src/command-line/init/init-v2.d.ts.map +1 -1
- package/src/command-line/init/init-v2.js +7 -35
- package/src/command-line/mcp/mcp.d.ts.map +1 -1
- package/src/command-line/mcp/mcp.js +2 -0
- package/src/command-line/migrate/migrate-ui-api.d.ts.map +1 -1
- package/src/command-line/migrate/migrate-ui-api.js +13 -0
- package/src/command-line/migrate/migrate.d.ts.map +1 -1
- package/src/command-line/migrate/migrate.js +16 -14
- package/src/command-line/migrate/run-migration-process.js +2 -0
- package/src/command-line/nx-cloud/connect/view-logs.js +1 -1
- package/src/command-line/nx-commands.js +65 -65
- package/src/command-line/release/config/version-plans.js +1 -1
- package/src/command-line/release/utils/exec-command.js +1 -1
- package/src/command-line/release/utils/launch-editor.js +2 -2
- package/src/command-line/release/utils/remote-release-clients/github.d.ts.map +1 -1
- package/src/command-line/release/utils/remote-release-clients/github.js +2 -1
- package/src/command-line/release/utils/remote-release-clients/gitlab.d.ts.map +1 -1
- package/src/command-line/release/utils/remote-release-clients/gitlab.js +1 -0
- package/src/command-line/release/version/release-group-processor.d.ts.map +1 -1
- package/src/command-line/release/version/release-group-processor.js +2 -4
- package/src/command-line/release/version.js +1 -1
- package/src/command-line/run/run.d.ts.map +1 -1
- package/src/command-line/run/run.js +2 -2
- package/src/command-line/watch/watch.js +1 -1
- package/src/core/graph/main.js +1 -1
- package/src/daemon/client/client.d.ts +1 -1
- package/src/daemon/client/client.d.ts.map +1 -1
- package/src/daemon/client/client.js +3 -2
- package/src/daemon/client/generate-help-output.js +1 -1
- package/src/daemon/server/handle-configure-ai-agents.js +11 -4
- package/src/daemon/server/handle-hash-tasks.d.ts +1 -0
- package/src/daemon/server/handle-hash-tasks.d.ts.map +1 -1
- package/src/daemon/server/handle-hash-tasks.js +1 -1
- package/src/daemon/server/shutdown-utils.js +1 -1
- package/src/executors/run-commands/run-commands.impl.d.ts.map +1 -1
- package/src/executors/run-commands/run-commands.impl.js +60 -7
- package/src/executors/run-commands/running-tasks.d.ts.map +1 -1
- package/src/executors/run-commands/running-tasks.js +1 -5
- package/src/executors/run-script/run-script.impl.js +1 -1
- package/src/hasher/native-task-hasher-impl.d.ts +2 -2
- package/src/hasher/native-task-hasher-impl.d.ts.map +1 -1
- package/src/hasher/native-task-hasher-impl.js +6 -6
- package/src/hasher/task-hasher.d.ts +4 -4
- package/src/hasher/task-hasher.d.ts.map +1 -1
- package/src/hasher/task-hasher.js +9 -6
- package/src/native/nx.wasm32-wasi.debug.wasm +0 -0
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +1 -1
- package/src/plugins/js/lock-file/bun-parser.js +1 -1
- package/src/plugins/js/lock-file/lock-file.d.ts.map +1 -1
- package/src/plugins/js/lock-file/lock-file.js +3 -1
- package/src/project-graph/file-utils.d.ts.map +1 -1
- package/src/project-graph/file-utils.js +4 -2
- package/src/tasks-runner/cache.js +1 -1
- package/src/tasks-runner/task-orchestrator.d.ts +4 -2
- package/src/tasks-runner/task-orchestrator.d.ts.map +1 -1
- package/src/tasks-runner/task-orchestrator.js +59 -32
- package/src/utils/ab-testing.js +1 -1
- package/src/utils/analytics-prompt.d.ts.map +1 -1
- package/src/utils/analytics-prompt.js +2 -0
- package/src/utils/child-process.d.ts.map +1 -1
- package/src/utils/child-process.js +1 -2
- package/src/utils/command-line-utils.js +3 -3
- package/src/utils/default-base.js +1 -1
- package/src/utils/git-utils.d.ts.map +1 -1
- package/src/utils/git-utils.index-filter.js +2 -2
- package/src/utils/git-utils.js +6 -5
- package/src/utils/git-utils.tree-filter.js +1 -1
- package/src/utils/machine-id-cache.d.ts.map +1 -1
- package/src/utils/machine-id-cache.js +72 -2
- package/src/utils/package-manager.d.ts.map +1 -1
- package/src/utils/package-manager.js +8 -13
- package/src/utils/require-nx-key.js +1 -1
- package/src/utils/serialize-overrides-into-command-line.d.ts.map +1 -1
- package/src/utils/serialize-overrides-into-command-line.js +3 -4
- package/src/utils/shell-quoting.d.ts +11 -0
- package/src/utils/shell-quoting.d.ts.map +1 -0
- package/src/utils/shell-quoting.js +41 -0
- package/src/command-line/init/implementation/react/add-craco-commands-to-package-scripts.d.ts +0 -2
- package/src/command-line/init/implementation/react/add-craco-commands-to-package-scripts.d.ts.map +0 -1
- package/src/command-line/init/implementation/react/add-craco-commands-to-package-scripts.js +0 -21
- package/src/command-line/init/implementation/react/add-vite-commands-to-package-scripts.d.ts +0 -2
- package/src/command-line/init/implementation/react/add-vite-commands-to-package-scripts.d.ts.map +0 -1
- package/src/command-line/init/implementation/react/add-vite-commands-to-package-scripts.js +0 -20
- package/src/command-line/init/implementation/react/check-for-custom-webpack-setup.d.ts +0 -2
- package/src/command-line/init/implementation/react/check-for-custom-webpack-setup.d.ts.map +0 -1
- package/src/command-line/init/implementation/react/check-for-custom-webpack-setup.js +0 -17
- package/src/command-line/init/implementation/react/check-for-uncommitted-changes.d.ts +0 -2
- package/src/command-line/init/implementation/react/check-for-uncommitted-changes.d.ts.map +0 -1
- package/src/command-line/init/implementation/react/check-for-uncommitted-changes.js +0 -20
- package/src/command-line/init/implementation/react/clean-up-files.d.ts +0 -2
- package/src/command-line/init/implementation/react/clean-up-files.d.ts.map +0 -1
- package/src/command-line/init/implementation/react/clean-up-files.js +0 -30
- package/src/command-line/init/implementation/react/index.d.ts +0 -5
- package/src/command-line/init/implementation/react/index.d.ts.map +0 -1
- package/src/command-line/init/implementation/react/index.js +0 -77
- package/src/command-line/init/implementation/react/read-name-from-package-json.d.ts +0 -2
- package/src/command-line/init/implementation/react/read-name-from-package-json.d.ts.map +0 -1
- package/src/command-line/init/implementation/react/read-name-from-package-json.js +0 -16
- package/src/command-line/init/implementation/react/rename-js-to-jsx.d.ts +0 -2
- package/src/command-line/init/implementation/react/rename-js-to-jsx.d.ts.map +0 -1
- package/src/command-line/init/implementation/react/rename-js-to-jsx.js +0 -22
- package/src/command-line/init/implementation/react/tsconfig-setup.d.ts +0 -2
- package/src/command-line/init/implementation/react/tsconfig-setup.d.ts.map +0 -1
- package/src/command-line/init/implementation/react/tsconfig-setup.js +0 -108
- package/src/command-line/init/implementation/react/write-vite-config.d.ts +0 -2
- package/src/command-line/init/implementation/react/write-vite-config.d.ts.map +0 -1
- package/src/command-line/init/implementation/react/write-vite-config.js +0 -53
- package/src/command-line/init/implementation/react/write-vite-index-html.d.ts +0 -2
- package/src/command-line/init/implementation/react/write-vite-index-html.d.ts.map +0 -1
- package/src/command-line/init/implementation/react/write-vite-index-html.js +0 -24
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.checkForCustomWebpackSetup = checkForCustomWebpackSetup;
|
|
4
|
-
const fileutils_1 = require("../../../../utils/fileutils");
|
|
5
|
-
function checkForCustomWebpackSetup() {
|
|
6
|
-
const packageJson = (0, fileutils_1.readJsonFile)('package.json');
|
|
7
|
-
const combinedDeps = {
|
|
8
|
-
...packageJson.dependencies,
|
|
9
|
-
...packageJson.devDependencies,
|
|
10
|
-
};
|
|
11
|
-
['react-app-rewired', '@craco/craco'].forEach((pkg) => {
|
|
12
|
-
if (combinedDeps[pkg]) {
|
|
13
|
-
console.log(`Skipping migration due to custom webpack setup. Found "${pkg}" usage. Use --force to continue anyway.`);
|
|
14
|
-
process.exit(1);
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"check-for-uncommitted-changes.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/nx/src/command-line/init/implementation/react/check-for-uncommitted-changes.ts"],"names":[],"mappings":"AAEA,wBAAgB,0BAA0B,SAiBzC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.checkForUncommittedChanges = checkForUncommittedChanges;
|
|
4
|
-
const child_process_1 = require("child_process");
|
|
5
|
-
function checkForUncommittedChanges() {
|
|
6
|
-
const gitResult = (0, child_process_1.execSync)('git status --porcelain', {
|
|
7
|
-
windowsHide: false,
|
|
8
|
-
}).toString();
|
|
9
|
-
const filteredResults = gitResult
|
|
10
|
-
.split('\n')
|
|
11
|
-
.filter((line) => !line.includes('.nx') && line.trim().length > 0);
|
|
12
|
-
if (filteredResults.length > 0) {
|
|
13
|
-
console.log('❗️ Careful!');
|
|
14
|
-
console.log('You have uncommitted changes in your repository.');
|
|
15
|
-
console.log('');
|
|
16
|
-
console.log(filteredResults.join('\n').toString());
|
|
17
|
-
console.log('Please commit your changes before running the migrator!');
|
|
18
|
-
process.exit(1);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"clean-up-files.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/nx/src/command-line/init/implementation/react/clean-up-files.ts"],"names":[],"mappings":"AAGA,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,QA6BlE"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.cleanUpFiles = cleanUpFiles;
|
|
4
|
-
const node_fs_1 = require("node:fs");
|
|
5
|
-
const fileutils_1 = require("../../../../utils/fileutils");
|
|
6
|
-
function cleanUpFiles(appName, isStandalone) {
|
|
7
|
-
// Delete targets from project since we delegate to npm scripts.
|
|
8
|
-
const projectJsonPath = isStandalone
|
|
9
|
-
? 'project.json'
|
|
10
|
-
: `apps/${appName}/project.json`;
|
|
11
|
-
const json = (0, fileutils_1.readJsonFile)(projectJsonPath);
|
|
12
|
-
delete json.targets;
|
|
13
|
-
if (isStandalone) {
|
|
14
|
-
if (json.sourceRoot) {
|
|
15
|
-
json.sourceRoot = json.sourceRoot.replace(`apps/${appName}/`, '');
|
|
16
|
-
}
|
|
17
|
-
if (json['$schema']) {
|
|
18
|
-
json['$schema'] = json['$schema'].replace('../../node_modules', 'node_modules');
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
(0, fileutils_1.writeJsonFile)(projectJsonPath, json);
|
|
22
|
-
(0, node_fs_1.rmSync)('temp-workspace', { recursive: true, force: true });
|
|
23
|
-
if (isStandalone) {
|
|
24
|
-
(0, node_fs_1.rmSync)('babel.config.json', { recursive: true, force: true });
|
|
25
|
-
(0, node_fs_1.rmSync)('jest.preset.js', { recursive: true, force: true });
|
|
26
|
-
(0, node_fs_1.rmSync)('jest.config.ts', { recursive: true, force: true });
|
|
27
|
-
(0, node_fs_1.rmSync)('libs', { recursive: true, force: true });
|
|
28
|
-
(0, node_fs_1.rmSync)('tools', { recursive: true, force: true });
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/nx/src/command-line/init/implementation/react/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAczC,KAAK,OAAO,GAAG,QAAQ,CAAC;AAUxB,wBAAsB,cAAc,CAAC,QAAQ,EAAE,OAAO,iBA8BrD"}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addNxToCraRepo = addNxToCraRepo;
|
|
4
|
-
const child_process_1 = require("child_process");
|
|
5
|
-
const path_1 = require("path");
|
|
6
|
-
const fs_1 = require("fs");
|
|
7
|
-
const fileutils_1 = require("../../../../utils/fileutils");
|
|
8
|
-
const output_1 = require("../../../../utils/output");
|
|
9
|
-
const package_manager_1 = require("../../../../utils/package-manager");
|
|
10
|
-
const check_for_custom_webpack_setup_1 = require("./check-for-custom-webpack-setup");
|
|
11
|
-
const read_name_from_package_json_1 = require("./read-name-from-package-json");
|
|
12
|
-
const rename_js_to_jsx_1 = require("./rename-js-to-jsx");
|
|
13
|
-
const write_vite_config_1 = require("./write-vite-config");
|
|
14
|
-
const write_vite_index_html_1 = require("./write-vite-index-html");
|
|
15
|
-
async function addNxToCraRepo(_options) {
|
|
16
|
-
if (!_options.force) {
|
|
17
|
-
(0, check_for_custom_webpack_setup_1.checkForCustomWebpackSetup)();
|
|
18
|
-
}
|
|
19
|
-
const options = await normalizeOptions(_options);
|
|
20
|
-
await addBundler(options);
|
|
21
|
-
(0, fs_1.appendFileSync)(`.gitignore`, '\nnode_modules');
|
|
22
|
-
(0, fs_1.appendFileSync)(`.gitignore`, '\ndist');
|
|
23
|
-
installDependencies(options);
|
|
24
|
-
// Vite expects index.html to be in the root as the main entry point.
|
|
25
|
-
const indexPath = options.isStandalone
|
|
26
|
-
? 'index.html'
|
|
27
|
-
: (0, path_1.join)('apps', options.reactAppName, 'index.html');
|
|
28
|
-
const oldIndexPath = options.isStandalone
|
|
29
|
-
? (0, path_1.join)('public', 'index.html')
|
|
30
|
-
: (0, path_1.join)('apps', options.reactAppName, 'public', 'index.html');
|
|
31
|
-
output_1.output.note({
|
|
32
|
-
title: `A new ${indexPath} has been created. Compare it to the previous ${oldIndexPath} file and make any changes needed, then delete the previous file.`,
|
|
33
|
-
});
|
|
34
|
-
if (_options.force) {
|
|
35
|
-
output_1.output.note({
|
|
36
|
-
title: `Using --force converts projects with custom Webpack setup. You will need to manually update your vite.config.js file to match the plugins used in your old Webpack configuration.`,
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
function installDependencies(options) {
|
|
41
|
-
const dependencies = [
|
|
42
|
-
'@rollup/plugin-replace',
|
|
43
|
-
'@testing-library/jest-dom',
|
|
44
|
-
'@vitejs/plugin-react',
|
|
45
|
-
'eslint-config-react-app',
|
|
46
|
-
'web-vitals',
|
|
47
|
-
'jest-watch-typeahead',
|
|
48
|
-
'vite',
|
|
49
|
-
'vitest',
|
|
50
|
-
];
|
|
51
|
-
(0, child_process_1.execSync)(`${options.pmc.addDev} ${dependencies.join(' ')}`, {
|
|
52
|
-
stdio: [0, 1, 2],
|
|
53
|
-
windowsHide: false,
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
async function normalizeOptions(options) {
|
|
57
|
-
const packageManager = (0, package_manager_1.detectPackageManager)();
|
|
58
|
-
const pmc = (0, package_manager_1.getPackageManagerCommand)(packageManager);
|
|
59
|
-
const appIsJs = !(0, fileutils_1.fileExists)(`tsconfig.json`);
|
|
60
|
-
const reactAppName = (0, read_name_from_package_json_1.readNameFromPackageJson)();
|
|
61
|
-
const isStandalone = !options.integrated;
|
|
62
|
-
return {
|
|
63
|
-
...options,
|
|
64
|
-
packageManager,
|
|
65
|
-
pmc,
|
|
66
|
-
appIsJs,
|
|
67
|
-
reactAppName,
|
|
68
|
-
isStandalone,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
async function addBundler(options) {
|
|
72
|
-
const { addViteCommandsToPackageScripts } = await Promise.resolve().then(() => require('./add-vite-commands-to-package-scripts'));
|
|
73
|
-
addViteCommandsToPackageScripts(options.reactAppName, options.isStandalone);
|
|
74
|
-
(0, write_vite_config_1.writeViteConfig)(options.reactAppName, options.isStandalone, options.appIsJs);
|
|
75
|
-
(0, write_vite_index_html_1.writeViteIndexHtml)(options.reactAppName, options.isStandalone, options.appIsJs);
|
|
76
|
-
await (0, rename_js_to_jsx_1.renameJsToJsx)(options.reactAppName, options.isStandalone);
|
|
77
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"read-name-from-package-json.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/nx/src/command-line/init/implementation/react/read-name-from-package-json.ts"],"names":[],"mappings":"AAEA,wBAAgB,uBAAuB,IAAI,MAAM,CAahD"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.readNameFromPackageJson = readNameFromPackageJson;
|
|
4
|
-
const fileutils_1 = require("../../../../utils/fileutils");
|
|
5
|
-
function readNameFromPackageJson() {
|
|
6
|
-
let appName = 'webapp';
|
|
7
|
-
if ((0, fileutils_1.fileExists)('package.json')) {
|
|
8
|
-
const json = (0, fileutils_1.readJsonFile)('package.json');
|
|
9
|
-
if (json['name'] &&
|
|
10
|
-
json['name'].length &&
|
|
11
|
-
json['name'].replace(/\s/g, '').length) {
|
|
12
|
-
appName = json['name'].replace(/\s/g, '');
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
return appName;
|
|
16
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rename-js-to-jsx.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/nx/src/command-line/init/implementation/react/rename-js-to-jsx.ts"],"names":[],"mappings":"AAKA,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,iBAezE"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.renameJsToJsx = renameJsToJsx;
|
|
4
|
-
const node_fs_1 = require("node:fs");
|
|
5
|
-
const workspace_context_1 = require("../../../../utils/workspace-context");
|
|
6
|
-
const fileutils_1 = require("../../../../utils/fileutils");
|
|
7
|
-
// Vite cannot process JSX like <div> or <Header> unless the file is named .jsx or .tsx
|
|
8
|
-
async function renameJsToJsx(appName, isStandalone) {
|
|
9
|
-
const files = await (0, workspace_context_1.globWithWorkspaceContext)(process.cwd(), [
|
|
10
|
-
isStandalone ? 'src/**/*.js' : `apps/${appName}/src/**/*.js`,
|
|
11
|
-
]);
|
|
12
|
-
files.forEach((file) => {
|
|
13
|
-
if ((0, fileutils_1.fileExists)(file)) {
|
|
14
|
-
const content = (0, node_fs_1.readFileSync)(file).toString();
|
|
15
|
-
// Try to detect JSX before renaming to .jsx
|
|
16
|
-
// Files like setupTests.js from CRA should not be renamed
|
|
17
|
-
if (/<[a-zA-Z0-9]+/.test(content)) {
|
|
18
|
-
(0, node_fs_1.renameSync)(file, `${file}x`);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tsconfig-setup.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/nx/src/command-line/init/implementation/react/tsconfig-setup.ts"],"names":[],"mappings":"AA+DA,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,QA+CnE"}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setupTsConfig = setupTsConfig;
|
|
4
|
-
const path_1 = require("path");
|
|
5
|
-
const fileutils_1 = require("../../../../utils/fileutils");
|
|
6
|
-
const defaultTsConfig = (relativePathToRoot) => ({
|
|
7
|
-
extends: relativePathToRoot
|
|
8
|
-
? (0, path_1.join)(relativePathToRoot, 'tsconfig.base.json')
|
|
9
|
-
: './tsconfig.base.json',
|
|
10
|
-
compilerOptions: {
|
|
11
|
-
jsx: 'react',
|
|
12
|
-
allowJs: true,
|
|
13
|
-
esModuleInterop: true,
|
|
14
|
-
allowSyntheticDefaultImports: true,
|
|
15
|
-
},
|
|
16
|
-
files: [],
|
|
17
|
-
include: [],
|
|
18
|
-
references: [
|
|
19
|
-
{
|
|
20
|
-
path: './tsconfig.app.json',
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
path: './tsconfig.spec.json',
|
|
24
|
-
},
|
|
25
|
-
],
|
|
26
|
-
});
|
|
27
|
-
const defaultTsConfigApp = (relativePathToRoot) => ({
|
|
28
|
-
extends: './tsconfig.json',
|
|
29
|
-
compilerOptions: {
|
|
30
|
-
outDir: (0, path_1.join)(relativePathToRoot, 'dist/out-tsc'),
|
|
31
|
-
types: ['node'],
|
|
32
|
-
},
|
|
33
|
-
files: [
|
|
34
|
-
(0, path_1.join)(relativePathToRoot, 'node_modules/@nx/react/typings/cssmodule.d.ts'),
|
|
35
|
-
(0, path_1.join)(relativePathToRoot, 'node_modules/@nx/react/typings/image.d.ts'),
|
|
36
|
-
],
|
|
37
|
-
exclude: ['**/*.spec.ts', '**/*.spec.tsx'],
|
|
38
|
-
include: ['**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx'],
|
|
39
|
-
});
|
|
40
|
-
const defaultTsConfigSpec = (relativePathToRoot) => ({
|
|
41
|
-
extends: './tsconfig.json',
|
|
42
|
-
compilerOptions: {
|
|
43
|
-
outDir: (0, path_1.join)(relativePathToRoot, 'dist/out-tsc'),
|
|
44
|
-
module: 'commonjs',
|
|
45
|
-
types: ['jest', 'node'],
|
|
46
|
-
},
|
|
47
|
-
include: [
|
|
48
|
-
'**/*.spec.ts',
|
|
49
|
-
'**/*.spec.tsx',
|
|
50
|
-
'**/*.spec.js',
|
|
51
|
-
'**/*.spec.jsx',
|
|
52
|
-
'**/*.d.ts',
|
|
53
|
-
],
|
|
54
|
-
files: [
|
|
55
|
-
(0, path_1.join)(relativePathToRoot, 'node_modules/@nx/react/typings/cssmodule.d.ts'),
|
|
56
|
-
(0, path_1.join)(relativePathToRoot, 'node_modules/@nx/react/typings/image.d.ts'),
|
|
57
|
-
],
|
|
58
|
-
});
|
|
59
|
-
function setupTsConfig(appName, isStandalone) {
|
|
60
|
-
const tsconfigPath = isStandalone
|
|
61
|
-
? 'tsconfig.json'
|
|
62
|
-
: `apps/${appName}/tsconfig.json`;
|
|
63
|
-
const tsconfigAppPath = isStandalone
|
|
64
|
-
? 'tsconfig.app.json'
|
|
65
|
-
: `apps/${appName}/tsconfig.app.json`;
|
|
66
|
-
const tsconfiSpecPath = isStandalone
|
|
67
|
-
? 'tsconfig.spec.json'
|
|
68
|
-
: `apps/${appName}/tsconfig.spec.json`;
|
|
69
|
-
const tsconfigBasePath = isStandalone
|
|
70
|
-
? './tsconfig.base.json'
|
|
71
|
-
: '../../tsconfig.base.json';
|
|
72
|
-
const relativePathToRoot = isStandalone ? '' : '../../';
|
|
73
|
-
if ((0, fileutils_1.fileExists)(tsconfigPath)) {
|
|
74
|
-
const json = (0, fileutils_1.readJsonFile)(tsconfigPath);
|
|
75
|
-
json.extends = tsconfigBasePath;
|
|
76
|
-
if (json.compilerOptions) {
|
|
77
|
-
json.compilerOptions.jsx = 'react';
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
json.compilerOptions = {
|
|
81
|
-
jsx: 'react',
|
|
82
|
-
allowJs: true,
|
|
83
|
-
esModuleInterop: true,
|
|
84
|
-
allowSyntheticDefaultImports: true,
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
(0, fileutils_1.writeJsonFile)(tsconfigPath, json);
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
(0, fileutils_1.writeJsonFile)(tsconfigPath, defaultTsConfig(relativePathToRoot));
|
|
91
|
-
}
|
|
92
|
-
if ((0, fileutils_1.fileExists)(tsconfigAppPath)) {
|
|
93
|
-
const json = (0, fileutils_1.readJsonFile)(tsconfigAppPath);
|
|
94
|
-
json.extends = './tsconfig.json';
|
|
95
|
-
(0, fileutils_1.writeJsonFile)(tsconfigAppPath, json);
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
(0, fileutils_1.writeJsonFile)(tsconfigAppPath, defaultTsConfigApp(relativePathToRoot));
|
|
99
|
-
}
|
|
100
|
-
if ((0, fileutils_1.fileExists)(tsconfiSpecPath)) {
|
|
101
|
-
const json = (0, fileutils_1.readJsonFile)(tsconfiSpecPath);
|
|
102
|
-
json.extends = './tsconfig.json';
|
|
103
|
-
(0, fileutils_1.writeJsonFile)(tsconfiSpecPath, json);
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
(0, fileutils_1.writeJsonFile)(tsconfiSpecPath, defaultTsConfigSpec(relativePathToRoot));
|
|
107
|
-
}
|
|
108
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"write-vite-config.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/nx/src/command-line/init/implementation/react/write-vite-config.ts"],"names":[],"mappings":"AAEA,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,OAAO,EACrB,IAAI,EAAE,OAAO,QAwDd"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.writeViteConfig = writeViteConfig;
|
|
4
|
-
const fs_1 = require("fs");
|
|
5
|
-
function writeViteConfig(appName, isStandalone, isJs) {
|
|
6
|
-
let port = 3000;
|
|
7
|
-
// Use PORT from .env file if it exists in project.
|
|
8
|
-
if ((0, fs_1.existsSync)(`../.env`)) {
|
|
9
|
-
const envFile = (0, fs_1.readFileSync)(`../.env`).toString();
|
|
10
|
-
const result = envFile.match(/\bport=(?<port>\d{4})/i);
|
|
11
|
-
const portCandidate = Number(result?.groups?.port);
|
|
12
|
-
if (!isNaN(portCandidate)) {
|
|
13
|
-
port = portCandidate;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
(0, fs_1.writeFileSync)(isStandalone ? 'vite.config.mjs' : `apps/${appName}/vite.config.mjs`, `import { defineConfig } from 'vite'
|
|
17
|
-
import react from '@vitejs/plugin-react'
|
|
18
|
-
import replace from '@rollup/plugin-replace';
|
|
19
|
-
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
|
|
20
|
-
|
|
21
|
-
// Match CRA's environment variables.
|
|
22
|
-
// TODO: Replace these with VITE_ prefixed environment variables, and using import.meta.env.VITE_* instead of process.env.REACT_APP_*.
|
|
23
|
-
const craEnvVarRegex = /^REACT_APP/i;
|
|
24
|
-
const craEnvVars = Object.keys(process.env)
|
|
25
|
-
.filter((key) => craEnvVarRegex.test(key))
|
|
26
|
-
.reduce((env, key) => {
|
|
27
|
-
env[\`process.env.\${key}\`] = JSON.stringify(process.env[key]);
|
|
28
|
-
return env;
|
|
29
|
-
}, {});
|
|
30
|
-
|
|
31
|
-
// https://vite.dev/config/
|
|
32
|
-
export default defineConfig({
|
|
33
|
-
build: {
|
|
34
|
-
outDir: ${isStandalone ? `'./dist/${appName}'` : `'../../dist/apps/${appName}'`}
|
|
35
|
-
},
|
|
36
|
-
server: {
|
|
37
|
-
port: ${port},
|
|
38
|
-
open: true,
|
|
39
|
-
},
|
|
40
|
-
test: {
|
|
41
|
-
globals: true,
|
|
42
|
-
environment: 'jsdom',
|
|
43
|
-
setupFiles: 'src/setupTests.${isJs ? 'js' : 'ts'}',
|
|
44
|
-
css: true,
|
|
45
|
-
},
|
|
46
|
-
plugins: [
|
|
47
|
-
react(),
|
|
48
|
-
replace({ values: craEnvVars, preventAssignment: true }),
|
|
49
|
-
nxViteTsPaths(),
|
|
50
|
-
],
|
|
51
|
-
});
|
|
52
|
-
`);
|
|
53
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"write-vite-index-html.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/nx/src/command-line/init/implementation/react/write-vite-index-html.ts"],"names":[],"mappings":"AAEA,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,OAAO,EACrB,IAAI,EAAE,OAAO,QAuBd"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.writeViteIndexHtml = writeViteIndexHtml;
|
|
4
|
-
const fs_1 = require("fs");
|
|
5
|
-
function writeViteIndexHtml(appName, isStandalone, isJs) {
|
|
6
|
-
const indexPath = isStandalone ? 'index.html' : `apps/${appName}/index.html`;
|
|
7
|
-
if ((0, fs_1.existsSync)(indexPath)) {
|
|
8
|
-
(0, fs_1.copyFileSync)(indexPath, indexPath + '.old');
|
|
9
|
-
}
|
|
10
|
-
const indexFile = isJs ? '/src/index.jsx' : '/src/index.tsx';
|
|
11
|
-
(0, fs_1.writeFileSync)(indexPath, `<!DOCTYPE html>
|
|
12
|
-
<html lang="en">
|
|
13
|
-
<head>
|
|
14
|
-
<meta charset="UTF-8" />
|
|
15
|
-
<link rel="icon" href="/favicon.ico" />
|
|
16
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
17
|
-
<title>Vite + React + Nx</title>
|
|
18
|
-
</head>
|
|
19
|
-
<body>
|
|
20
|
-
<div id="root"></div>
|
|
21
|
-
<script type="module" src="${indexFile}"></script>
|
|
22
|
-
</body>
|
|
23
|
-
</html>`);
|
|
24
|
-
}
|