@mnci/cli 4.22.0 → 4.23.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/README.md +2 -2
- package/dist/cli.js +44 -14
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -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
|
@@ -2678,6 +2678,33 @@ function renameScaffoldPlaceholder(projectRoot, name) {
|
|
|
2678
2678
|
function reshapeReactScaffold(projectRoot, name) {
|
|
2679
2679
|
reshapeScaffoldSlice(projectRoot, name, "tsx", "component");
|
|
2680
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
|
+
}
|
|
2681
2708
|
function reshapeScaffoldSlice(projectRoot, name, extension, role) {
|
|
2682
2709
|
const sourceDir = (0, import_node_path5.join)(projectRoot, "src");
|
|
2683
2710
|
const libDir = (0, import_node_path5.join)(sourceDir, "lib");
|
|
@@ -2710,7 +2737,11 @@ function reshapeScaffoldSlice(projectRoot, name, extension, role) {
|
|
|
2710
2737
|
(0, import_node_fs5.rmSync)(libDir, { recursive: true, force: true });
|
|
2711
2738
|
}
|
|
2712
2739
|
function repointSpecifier(source, from, to) {
|
|
2713
|
-
|
|
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;
|
|
2714
2745
|
}
|
|
2715
2746
|
function ensureNxPeerOverrides(workspaceRoot) {
|
|
2716
2747
|
const manifestPath = (0, import_node_path5.join)(workspaceRoot, "package.json");
|
|
@@ -3973,8 +4004,8 @@ function ensureAzureFunctionsPackage(workspaceRoot) {
|
|
|
3973
4004
|
}
|
|
3974
4005
|
}
|
|
3975
4006
|
var NODE_FUNCTION_APP_MAIN = `// esbuild only includes what is reachable from here, so add one import per
|
|
3976
|
-
// function
|
|
3977
|
-
import './
|
|
4007
|
+
// function slice you create under src/ (through its index).
|
|
4008
|
+
import './hello'
|
|
3978
4009
|
`;
|
|
3979
4010
|
var NODE_FUNCTION_APP_HOST_JSON = `{
|
|
3980
4011
|
"version": "2.0",
|
|
@@ -3986,7 +4017,7 @@ var NODE_FUNCTION_APP_HOST_JSON = `{
|
|
|
3986
4017
|
`;
|
|
3987
4018
|
var NODE_FUNCTION_APP_HELLO = `import { app } from '@azure/functions'
|
|
3988
4019
|
import type { HttpRequest, HttpResponseInit } from '@azure/functions'
|
|
3989
|
-
import { buildGreeting } from './greeting'
|
|
4020
|
+
import { buildGreeting } from './greeting.algorithm'
|
|
3990
4021
|
|
|
3991
4022
|
async function hello(request: HttpRequest): Promise<HttpResponseInit> {
|
|
3992
4023
|
const name = request.query.get('name') ?? 'world'
|
|
@@ -4000,11 +4031,13 @@ app.http('hello', {
|
|
|
4000
4031
|
handler: hello,
|
|
4001
4032
|
})
|
|
4002
4033
|
`;
|
|
4034
|
+
var NODE_FUNCTION_APP_HELLO_BARREL = `export * from './hello.handler'
|
|
4035
|
+
`;
|
|
4003
4036
|
var NODE_FUNCTION_APP_GREETING = `export function buildGreeting (name: string): string {
|
|
4004
4037
|
return 'Hello, ' + name + '!'
|
|
4005
4038
|
}
|
|
4006
4039
|
`;
|
|
4007
|
-
var NODE_FUNCTION_APP_GREETING_SPEC = `import { buildGreeting } from './greeting'
|
|
4040
|
+
var NODE_FUNCTION_APP_GREETING_SPEC = `import { buildGreeting } from './greeting.algorithm'
|
|
4008
4041
|
|
|
4009
4042
|
describe('buildGreeting', () => {
|
|
4010
4043
|
it('greets a name', () => {
|
|
@@ -4061,15 +4094,10 @@ function addNodeFunctionApp(workspaceRoot, name, stack) {
|
|
|
4061
4094
|
ensureAzureFunctionsPackage(workspaceRoot);
|
|
4062
4095
|
const nodeFunctionAppRoot = (0, import_node_path12.join)(workspaceRoot, "apps", name);
|
|
4063
4096
|
writeFileEnsured((0, import_node_path12.join)(nodeFunctionAppRoot, "src/main.ts"), NODE_FUNCTION_APP_MAIN);
|
|
4064
|
-
writeFileEnsured((0, import_node_path12.join)(nodeFunctionAppRoot, "src/
|
|
4065
|
-
writeFileEnsured(
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
);
|
|
4069
|
-
writeFileEnsured(
|
|
4070
|
-
(0, import_node_path12.join)(nodeFunctionAppRoot, "src/functions/greeting.spec.ts"),
|
|
4071
|
-
NODE_FUNCTION_APP_GREETING_SPEC
|
|
4072
|
-
);
|
|
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);
|
|
4073
4101
|
writeFileEnsured((0, import_node_path12.join)(nodeFunctionAppRoot, "host.json"), NODE_FUNCTION_APP_HOST_JSON);
|
|
4074
4102
|
repairNodeFunctionAppManifest(nodeFunctionAppRoot, workspaceRoot);
|
|
4075
4103
|
ensureAdmZip(workspaceRoot);
|
|
@@ -4738,6 +4766,7 @@ function addReactApp(workspaceRoot, name, stack) {
|
|
|
4738
4766
|
}
|
|
4739
4767
|
allowEnvFiles(workspaceRoot);
|
|
4740
4768
|
addNxTargets((0, import_node_path18.join)(reactAppRoot, "package.json"), reactAppTargets(name));
|
|
4769
|
+
reshapeReactAppScaffold(reactAppRoot);
|
|
4741
4770
|
removeGeneratedEslintConfig(workspaceRoot, `apps/${name}`);
|
|
4742
4771
|
registerProjectCommands(workspaceRoot, name, { build: true, start: `nx run ${name}:serve` });
|
|
4743
4772
|
}
|
|
@@ -4799,6 +4828,7 @@ function addReactInternalLib(workspaceRoot, name, stack) {
|
|
|
4799
4828
|
repairPublishableManifest(privateManifest);
|
|
4800
4829
|
repairDeclarationSpecifiers(projectRoot);
|
|
4801
4830
|
writeProjectReadme(projectRoot, name, stack.testRunner);
|
|
4831
|
+
reshapeReactScaffold(projectRoot, name);
|
|
4802
4832
|
removeGeneratedEslintConfig(workspaceRoot, `libs/${name}`);
|
|
4803
4833
|
registerProjectCommands(workspaceRoot, name, { build: true });
|
|
4804
4834
|
}
|