@mnci/cli 4.21.0 → 4.23.0
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/README.md +3 -3
- package/dist/cli.js +65 -29
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -204,7 +204,7 @@ value always wins.
|
|
|
204
204
|
swc's `transform()` without `sourceMaps`, so swc returns no map, the rollup
|
|
205
205
|
chain breaks, and the map comes out valid-looking and **empty** — `sources: []`.
|
|
206
206
|
Measured on a real package: swc gave 0 sources, babel gave 9. Revert the swap
|
|
207
|
-
once Nx passes `sourceMaps` through;
|
|
207
|
+
once Nx passes `sourceMaps` through; issue #308 has the one-line upstream fix.
|
|
208
208
|
|
|
209
209
|
Re-measured against the exact toolchain `mnci new` pins today (Nx 23.2.0,
|
|
210
210
|
`@swc/core` 1.15.8): `@nx/rollup`'s swc plugin still does **not** pass
|
|
@@ -1335,12 +1335,12 @@ already use:
|
|
|
1335
1335
|
- **`node-function-app` overlay**: `@azure/functions` is installed for real
|
|
1336
1336
|
(a plain `@nx/node:application` app has no Azure dependency by default,
|
|
1337
1337
|
unlike a plugin-generated one), an HTTP-triggered `app.http(...)` sample
|
|
1338
|
-
(v4 programming model) is written
|
|
1338
|
+
(v4 programming model) is written as a `src/hello/` slice (`hello.handler.ts` plus a pure `greeting.algorithm.ts` and its spec, behind an `index.ts`), `host.json` is
|
|
1339
1339
|
added, and the manifest is repaired — `main: 'main.js'` (the dist shim) and
|
|
1340
1340
|
`@azure/functions` added to `dependencies` for Azure's deploy-time install
|
|
1341
1341
|
to find.
|
|
1342
1342
|
- **Convention** (both kinds): `src/main.ts` is the esbuild entry — add one
|
|
1343
|
-
import per function
|
|
1343
|
+
import per function slice you create under `src/` (through its `index.ts`), or it won't be
|
|
1344
1344
|
reachable (and thus won't be transpiled into `dist`).
|
|
1345
1345
|
|
|
1346
1346
|
## How React apps work (one build per environment)
|
package/dist/cli.js
CHANGED
|
@@ -2673,27 +2673,60 @@ function projectTask(name, kind) {
|
|
|
2673
2673
|
return kind === "start" ? { ...base, isBackground: true } : { ...base, group: kind };
|
|
2674
2674
|
}
|
|
2675
2675
|
function renameScaffoldPlaceholder(projectRoot, name) {
|
|
2676
|
+
reshapeScaffoldSlice(projectRoot, name, "ts", "use-case");
|
|
2677
|
+
}
|
|
2678
|
+
function reshapeReactScaffold(projectRoot, name) {
|
|
2679
|
+
reshapeScaffoldSlice(projectRoot, name, "tsx", "component");
|
|
2680
|
+
}
|
|
2681
|
+
function reshapeReactAppScaffold(projectRoot) {
|
|
2682
|
+
const appDir = (0, import_node_path5.join)(projectRoot, "src", "app");
|
|
2683
|
+
if (!(0, import_node_fs5.existsSync)((0, import_node_path5.join)(appDir, "app.tsx"))) {
|
|
2684
|
+
return;
|
|
2685
|
+
}
|
|
2686
|
+
for (const [from, to] of [
|
|
2687
|
+
["app.tsx", "app.component.tsx"],
|
|
2688
|
+
["app.spec.tsx", "app.component.spec.tsx"],
|
|
2689
|
+
["nx-welcome.tsx", "nx-welcome.component.tsx"]
|
|
2690
|
+
]) {
|
|
2691
|
+
if ((0, import_node_fs5.existsSync)((0, import_node_path5.join)(appDir, from))) {
|
|
2692
|
+
(0, import_node_fs5.renameSync)((0, import_node_path5.join)(appDir, from), (0, import_node_path5.join)(appDir, to));
|
|
2693
|
+
}
|
|
2694
|
+
}
|
|
2695
|
+
const rewrite = (file, from, to) => {
|
|
2696
|
+
if ((0, import_node_fs5.existsSync)(file)) {
|
|
2697
|
+
writeFileEnsured(file, repointSpecifier((0, import_node_fs5.readFileSync)(file, "utf8"), from, to));
|
|
2698
|
+
}
|
|
2699
|
+
};
|
|
2700
|
+
rewrite((0, import_node_path5.join)(appDir, "app.component.tsx"), "./nx-welcome", "./nx-welcome.component");
|
|
2701
|
+
rewrite((0, import_node_path5.join)(appDir, "app.component.spec.tsx"), "./app", "./app.component");
|
|
2702
|
+
rewrite((0, import_node_path5.join)(projectRoot, "src", "main.tsx"), "./app/app", "./app");
|
|
2703
|
+
writeFileEnsured(
|
|
2704
|
+
(0, import_node_path5.join)(appDir, "index.ts"),
|
|
2705
|
+
"export * from './app.component'\nexport { default } from './app.component'\n"
|
|
2706
|
+
);
|
|
2707
|
+
}
|
|
2708
|
+
function reshapeScaffoldSlice(projectRoot, name, extension, role) {
|
|
2676
2709
|
const sourceDir = (0, import_node_path5.join)(projectRoot, "src");
|
|
2677
|
-
const
|
|
2678
|
-
if (!(0, import_node_fs5.existsSync)(
|
|
2710
|
+
const libDir = (0, import_node_path5.join)(sourceDir, "lib");
|
|
2711
|
+
if (!(0, import_node_fs5.existsSync)((0, import_node_path5.join)(libDir, `${name}.${extension}`))) {
|
|
2679
2712
|
return;
|
|
2680
2713
|
}
|
|
2681
2714
|
const sliceDir = (0, import_node_path5.join)(sourceDir, name);
|
|
2682
2715
|
(0, import_node_fs5.mkdirSync)(sliceDir, { recursive: true });
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
renamed,
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2716
|
+
for (const entry of (0, import_node_fs5.readdirSync)(libDir)) {
|
|
2717
|
+
if (entry === `${name}.${extension}`) {
|
|
2718
|
+
(0, import_node_fs5.renameSync)((0, import_node_path5.join)(libDir, entry), (0, import_node_path5.join)(sliceDir, `${name}.${role}.${extension}`));
|
|
2719
|
+
} else if (entry === `${name}.spec.${extension}`) {
|
|
2720
|
+
const renamed = (0, import_node_path5.join)(sliceDir, `${name}.${role}.spec.${extension}`);
|
|
2721
|
+
(0, import_node_fs5.renameSync)((0, import_node_path5.join)(libDir, entry), renamed);
|
|
2722
|
+
writeFileEnsured(renamed, repointSpecifier((0, import_node_fs5.readFileSync)(renamed, "utf8"), `./${name}`, `./${name}.${role}`));
|
|
2723
|
+
} else {
|
|
2724
|
+
(0, import_node_fs5.renameSync)((0, import_node_path5.join)(libDir, entry), (0, import_node_path5.join)(sliceDir, entry));
|
|
2725
|
+
}
|
|
2693
2726
|
}
|
|
2694
2727
|
const barrel = (0, import_node_path5.join)(sourceDir, "index.ts");
|
|
2695
2728
|
const esm = (0, import_node_fs5.existsSync)(barrel) && (0, import_node_fs5.readFileSync)(barrel, "utf8").includes(`./lib/${name}.js'`);
|
|
2696
|
-
writeFileEnsured((0, import_node_path5.join)(sliceDir, "index.ts"), `export * from './${name}
|
|
2729
|
+
writeFileEnsured((0, import_node_path5.join)(sliceDir, "index.ts"), `export * from './${name}.${role}${esm ? ".js" : ""}'
|
|
2697
2730
|
`);
|
|
2698
2731
|
if ((0, import_node_fs5.existsSync)(barrel)) {
|
|
2699
2732
|
writeFileEnsured(
|
|
@@ -2701,10 +2734,14 @@ function renameScaffoldPlaceholder(projectRoot, name) {
|
|
|
2701
2734
|
(0, import_node_fs5.readFileSync)(barrel, "utf8").replaceAll(`./lib/${name}.js'`, () => `./${name}/index.js'`).replaceAll(`./lib/${name}'`, () => `./${name}'`)
|
|
2702
2735
|
);
|
|
2703
2736
|
}
|
|
2704
|
-
(0, import_node_fs5.rmSync)(
|
|
2737
|
+
(0, import_node_fs5.rmSync)(libDir, { recursive: true, force: true });
|
|
2705
2738
|
}
|
|
2706
2739
|
function repointSpecifier(source, from, to) {
|
|
2707
|
-
|
|
2740
|
+
let result = source;
|
|
2741
|
+
for (const quote of ["'", '"']) {
|
|
2742
|
+
result = result.replaceAll(`${from}${quote}`, () => `${to}${quote}`).replaceAll(`${from}.js${quote}`, () => `${to}.js${quote}`);
|
|
2743
|
+
}
|
|
2744
|
+
return result;
|
|
2708
2745
|
}
|
|
2709
2746
|
function ensureNxPeerOverrides(workspaceRoot) {
|
|
2710
2747
|
const manifestPath = (0, import_node_path5.join)(workspaceRoot, "package.json");
|
|
@@ -3967,8 +4004,8 @@ function ensureAzureFunctionsPackage(workspaceRoot) {
|
|
|
3967
4004
|
}
|
|
3968
4005
|
}
|
|
3969
4006
|
var NODE_FUNCTION_APP_MAIN = `// esbuild only includes what is reachable from here, so add one import per
|
|
3970
|
-
// function
|
|
3971
|
-
import './
|
|
4007
|
+
// function slice you create under src/ (through its index).
|
|
4008
|
+
import './hello'
|
|
3972
4009
|
`;
|
|
3973
4010
|
var NODE_FUNCTION_APP_HOST_JSON = `{
|
|
3974
4011
|
"version": "2.0",
|
|
@@ -3980,7 +4017,7 @@ var NODE_FUNCTION_APP_HOST_JSON = `{
|
|
|
3980
4017
|
`;
|
|
3981
4018
|
var NODE_FUNCTION_APP_HELLO = `import { app } from '@azure/functions'
|
|
3982
4019
|
import type { HttpRequest, HttpResponseInit } from '@azure/functions'
|
|
3983
|
-
import { buildGreeting } from './greeting'
|
|
4020
|
+
import { buildGreeting } from './greeting.algorithm'
|
|
3984
4021
|
|
|
3985
4022
|
async function hello(request: HttpRequest): Promise<HttpResponseInit> {
|
|
3986
4023
|
const name = request.query.get('name') ?? 'world'
|
|
@@ -3994,11 +4031,13 @@ app.http('hello', {
|
|
|
3994
4031
|
handler: hello,
|
|
3995
4032
|
})
|
|
3996
4033
|
`;
|
|
4034
|
+
var NODE_FUNCTION_APP_HELLO_BARREL = `export * from './hello.handler'
|
|
4035
|
+
`;
|
|
3997
4036
|
var NODE_FUNCTION_APP_GREETING = `export function buildGreeting (name: string): string {
|
|
3998
4037
|
return 'Hello, ' + name + '!'
|
|
3999
4038
|
}
|
|
4000
4039
|
`;
|
|
4001
|
-
var NODE_FUNCTION_APP_GREETING_SPEC = `import { buildGreeting } from './greeting'
|
|
4040
|
+
var NODE_FUNCTION_APP_GREETING_SPEC = `import { buildGreeting } from './greeting.algorithm'
|
|
4002
4041
|
|
|
4003
4042
|
describe('buildGreeting', () => {
|
|
4004
4043
|
it('greets a name', () => {
|
|
@@ -4055,15 +4094,10 @@ function addNodeFunctionApp(workspaceRoot, name, stack) {
|
|
|
4055
4094
|
ensureAzureFunctionsPackage(workspaceRoot);
|
|
4056
4095
|
const nodeFunctionAppRoot = (0, import_node_path12.join)(workspaceRoot, "apps", name);
|
|
4057
4096
|
writeFileEnsured((0, import_node_path12.join)(nodeFunctionAppRoot, "src/main.ts"), NODE_FUNCTION_APP_MAIN);
|
|
4058
|
-
writeFileEnsured((0, import_node_path12.join)(nodeFunctionAppRoot, "src/
|
|
4059
|
-
writeFileEnsured(
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
);
|
|
4063
|
-
writeFileEnsured(
|
|
4064
|
-
(0, import_node_path12.join)(nodeFunctionAppRoot, "src/functions/greeting.spec.ts"),
|
|
4065
|
-
NODE_FUNCTION_APP_GREETING_SPEC
|
|
4066
|
-
);
|
|
4097
|
+
writeFileEnsured((0, import_node_path12.join)(nodeFunctionAppRoot, "src/hello/hello.handler.ts"), NODE_FUNCTION_APP_HELLO);
|
|
4098
|
+
writeFileEnsured((0, import_node_path12.join)(nodeFunctionAppRoot, "src/hello/greeting.algorithm.ts"), NODE_FUNCTION_APP_GREETING);
|
|
4099
|
+
writeFileEnsured((0, import_node_path12.join)(nodeFunctionAppRoot, "src/hello/greeting.algorithm.spec.ts"), NODE_FUNCTION_APP_GREETING_SPEC);
|
|
4100
|
+
writeFileEnsured((0, import_node_path12.join)(nodeFunctionAppRoot, "src/hello/index.ts"), NODE_FUNCTION_APP_HELLO_BARREL);
|
|
4067
4101
|
writeFileEnsured((0, import_node_path12.join)(nodeFunctionAppRoot, "host.json"), NODE_FUNCTION_APP_HOST_JSON);
|
|
4068
4102
|
repairNodeFunctionAppManifest(nodeFunctionAppRoot, workspaceRoot);
|
|
4069
4103
|
ensureAdmZip(workspaceRoot);
|
|
@@ -4136,7 +4170,7 @@ function sourceMapCapableCompiler(indent) {
|
|
|
4136
4170
|
return [
|
|
4137
4171
|
`${indent}// Swapped from swc by MoNecromanCI. @nx/rollup runs swc without`,
|
|
4138
4172
|
`${indent}// sourceMaps, so it returns no map and the bundle's map comes out empty -`,
|
|
4139
|
-
`${indent}// valid-looking, and useless for debugging. See
|
|
4173
|
+
`${indent}// valid-looking, and useless for debugging. See issue #308.`,
|
|
4140
4174
|
`${indent}compiler: 'babel',`
|
|
4141
4175
|
].join("\n");
|
|
4142
4176
|
}
|
|
@@ -4732,6 +4766,7 @@ function addReactApp(workspaceRoot, name, stack) {
|
|
|
4732
4766
|
}
|
|
4733
4767
|
allowEnvFiles(workspaceRoot);
|
|
4734
4768
|
addNxTargets((0, import_node_path18.join)(reactAppRoot, "package.json"), reactAppTargets(name));
|
|
4769
|
+
reshapeReactAppScaffold(reactAppRoot);
|
|
4735
4770
|
removeGeneratedEslintConfig(workspaceRoot, `apps/${name}`);
|
|
4736
4771
|
registerProjectCommands(workspaceRoot, name, { build: true, start: `nx run ${name}:serve` });
|
|
4737
4772
|
}
|
|
@@ -4764,6 +4799,7 @@ async function addReactLib(workspaceRoot, name, options, kindProvided, stack) {
|
|
|
4764
4799
|
repairPublishableManifest(publishableManifest);
|
|
4765
4800
|
repairDeclarationSpecifiers(projectRoot);
|
|
4766
4801
|
writeProjectReadme(projectRoot, `${scope}/${name}`, stack.testRunner);
|
|
4802
|
+
reshapeReactScaffold(projectRoot, name);
|
|
4767
4803
|
removeGeneratedEslintConfig(workspaceRoot, `packages/${name}`);
|
|
4768
4804
|
removeLocalRegistryScaffolding(workspaceRoot);
|
|
4769
4805
|
registerProjectCommands(workspaceRoot, name, { build: true });
|