@mnci/cli 4.25.0 → 4.26.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 +1 -1
- package/dist/cli.js +34 -17
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1336,7 +1336,7 @@ already use:
|
|
|
1336
1336
|
- **`node-function-app` overlay**: `@azure/functions` is installed for real
|
|
1337
1337
|
(a plain `@nx/node:application` app has no Azure dependency by default,
|
|
1338
1338
|
unlike a plugin-generated one), an HTTP-triggered `app.http(...)` sample
|
|
1339
|
-
(v4 programming model) is written as a `src/hello/` slice (`hello.handler.ts`
|
|
1339
|
+
(v4 programming model) is written as a `src/hello/` slice (`hello.handler.ts` adapting the transport, `greet.use-case.ts` and its spec, `greeting.contract.ts`, behind an `index.ts`; `--empty` skips the slice), `host.json` is
|
|
1340
1340
|
added, and the manifest is repaired — `main: 'main.js'` (the dist shim) and
|
|
1341
1341
|
`@azure/functions` added to `dependencies` for Azure's deploy-time install
|
|
1342
1342
|
to find.
|
package/dist/cli.js
CHANGED
|
@@ -4066,6 +4066,10 @@ var NODE_FUNCTION_APP_MAIN = `// esbuild only includes what is reachable from he
|
|
|
4066
4066
|
// function slice you create under src/ (through its index).
|
|
4067
4067
|
import './hello'
|
|
4068
4068
|
`;
|
|
4069
|
+
var NODE_FUNCTION_APP_MAIN_EMPTY = `// esbuild only includes what is reachable from here, so import each function slice
|
|
4070
|
+
// you create under src/ (through its index).
|
|
4071
|
+
export {}
|
|
4072
|
+
`;
|
|
4069
4073
|
var NODE_FUNCTION_APP_HOST_JSON = `{
|
|
4070
4074
|
"version": "2.0",
|
|
4071
4075
|
"extensionBundle": {
|
|
@@ -4076,11 +4080,11 @@ var NODE_FUNCTION_APP_HOST_JSON = `{
|
|
|
4076
4080
|
`;
|
|
4077
4081
|
var NODE_FUNCTION_APP_HELLO = `import { app } from '@azure/functions'
|
|
4078
4082
|
import type { HttpRequest, HttpResponseInit } from '@azure/functions'
|
|
4079
|
-
import {
|
|
4083
|
+
import { greet } from './greet.use-case'
|
|
4080
4084
|
|
|
4081
4085
|
async function hello(request: HttpRequest): Promise<HttpResponseInit> {
|
|
4082
4086
|
const name = request.query.get('name') ?? 'world'
|
|
4083
|
-
return { body:
|
|
4087
|
+
return { body: greet(name).message }
|
|
4084
4088
|
}
|
|
4085
4089
|
|
|
4086
4090
|
app.http('hello', {
|
|
@@ -4092,15 +4096,22 @@ app.http('hello', {
|
|
|
4092
4096
|
`;
|
|
4093
4097
|
var NODE_FUNCTION_APP_HELLO_BARREL = `export * from './hello.handler'
|
|
4094
4098
|
`;
|
|
4095
|
-
var
|
|
4096
|
-
|
|
4099
|
+
var NODE_FUNCTION_APP_GREETING_CONTRACT = `/** What greeting someone returns. */
|
|
4100
|
+
export interface Greeting {
|
|
4101
|
+
readonly message: string
|
|
4097
4102
|
}
|
|
4098
4103
|
`;
|
|
4099
|
-
var
|
|
4104
|
+
var NODE_FUNCTION_APP_GREET_USE_CASE = `import type { Greeting } from './greeting.contract'
|
|
4100
4105
|
|
|
4101
|
-
|
|
4106
|
+
export function greet (name: string): Greeting {
|
|
4107
|
+
return { message: 'Hello, ' + name + '!' }
|
|
4108
|
+
}
|
|
4109
|
+
`;
|
|
4110
|
+
var NODE_FUNCTION_APP_GREET_SPEC = `import { greet } from './greet.use-case'
|
|
4111
|
+
|
|
4112
|
+
describe('greet', () => {
|
|
4102
4113
|
it('greets a name', () => {
|
|
4103
|
-
expect(
|
|
4114
|
+
expect(greet('world')).toEqual({ message: 'Hello, world!' })
|
|
4104
4115
|
})
|
|
4105
4116
|
})
|
|
4106
4117
|
`;
|
|
@@ -4148,22 +4159,28 @@ function nodeFunctionAppStartTarget(name) {
|
|
|
4148
4159
|
options: { command: "func start", cwd: `apps/${name}` }
|
|
4149
4160
|
};
|
|
4150
4161
|
}
|
|
4151
|
-
function addNodeFunctionApp(workspaceRoot, name, stack) {
|
|
4162
|
+
function addNodeFunctionApp(workspaceRoot, name, stack, empty = false) {
|
|
4152
4163
|
runNodeApp(workspaceRoot, name, stack, "none");
|
|
4153
4164
|
ensureAzureFunctionsPackage(workspaceRoot);
|
|
4154
4165
|
const nodeFunctionAppRoot = (0, import_node_path12.join)(workspaceRoot, "apps", name);
|
|
4155
|
-
writeFileEnsured((0, import_node_path12.join)(nodeFunctionAppRoot, "src/main.ts"), NODE_FUNCTION_APP_MAIN);
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4166
|
+
writeFileEnsured((0, import_node_path12.join)(nodeFunctionAppRoot, "src/main.ts"), empty ? NODE_FUNCTION_APP_MAIN_EMPTY : NODE_FUNCTION_APP_MAIN);
|
|
4167
|
+
if (!empty) {
|
|
4168
|
+
const slice = (0, import_node_path12.join)(nodeFunctionAppRoot, "src/hello");
|
|
4169
|
+
writeFileEnsured((0, import_node_path12.join)(slice, "hello.handler.ts"), NODE_FUNCTION_APP_HELLO);
|
|
4170
|
+
writeFileEnsured((0, import_node_path12.join)(slice, "greet.use-case.ts"), NODE_FUNCTION_APP_GREET_USE_CASE);
|
|
4171
|
+
writeFileEnsured((0, import_node_path12.join)(slice, "greet.use-case.spec.ts"), NODE_FUNCTION_APP_GREET_SPEC);
|
|
4172
|
+
writeFileEnsured((0, import_node_path12.join)(slice, "greeting.contract.ts"), NODE_FUNCTION_APP_GREETING_CONTRACT);
|
|
4173
|
+
writeFileEnsured((0, import_node_path12.join)(slice, "index.ts"), NODE_FUNCTION_APP_HELLO_BARREL);
|
|
4174
|
+
}
|
|
4160
4175
|
writeFileEnsured((0, import_node_path12.join)(nodeFunctionAppRoot, "host.json"), NODE_FUNCTION_APP_HOST_JSON);
|
|
4161
4176
|
repairNodeFunctionAppManifest(nodeFunctionAppRoot, workspaceRoot);
|
|
4162
4177
|
ensureAdmZip(workspaceRoot);
|
|
4163
4178
|
addNxTargets((0, import_node_path12.join)(nodeFunctionAppRoot, "package.json"), {
|
|
4164
4179
|
package: nodeFunctionAppPackageTarget(name),
|
|
4165
4180
|
prune: nodeFunctionAppPruneTarget(name),
|
|
4166
|
-
start: nodeFunctionAppStartTarget(name)
|
|
4181
|
+
start: nodeFunctionAppStartTarget(name),
|
|
4182
|
+
// With no spec the runner exits non-zero; an empty scaffold must still pass `nx test`.
|
|
4183
|
+
...empty && { test: { options: { passWithNoTests: true } } }
|
|
4167
4184
|
});
|
|
4168
4185
|
removeGeneratedEslintConfig(workspaceRoot, `apps/${name}`);
|
|
4169
4186
|
registerProjectCommands(workspaceRoot, name, { build: true, start: `nx run ${name}:start` });
|
|
@@ -6542,7 +6559,7 @@ var PROJECT_KINDS = [
|
|
|
6542
6559
|
"csharp-internal-lib",
|
|
6543
6560
|
"vscode-extension"
|
|
6544
6561
|
];
|
|
6545
|
-
var EMPTY_KINDS = /* @__PURE__ */ new Set(["npm-lib", "internal-lib", "react-lib", "react-internal-lib"]);
|
|
6562
|
+
var EMPTY_KINDS = /* @__PURE__ */ new Set(["npm-lib", "internal-lib", "react-lib", "react-internal-lib", "node-function-app"]);
|
|
6546
6563
|
async function runAdd(kind, name, options) {
|
|
6547
6564
|
const workspaceRoot = process.cwd();
|
|
6548
6565
|
if (!fileExists((0, import_node_path25.join)(workspaceRoot, "nx.json"))) {
|
|
@@ -6588,7 +6605,7 @@ async function runAdd(kind, name, options) {
|
|
|
6588
6605
|
break;
|
|
6589
6606
|
}
|
|
6590
6607
|
case "node-function-app": {
|
|
6591
|
-
addNodeFunctionApp(workspaceRoot, resolvedName, stack);
|
|
6608
|
+
addNodeFunctionApp(workspaceRoot, resolvedName, stack, options.empty === true);
|
|
6592
6609
|
break;
|
|
6593
6610
|
}
|
|
6594
6611
|
case "npm-lib": {
|
|
@@ -7706,7 +7723,7 @@ function buildProgram(cliVersion) {
|
|
|
7706
7723
|
"node-app only: express | fastify | koa | nest | none (default: none)"
|
|
7707
7724
|
).option(
|
|
7708
7725
|
"--empty",
|
|
7709
|
-
"npm-lib, internal-lib, react-lib, react-internal-lib: scaffold the slice skeleton only, with no sample code or spec"
|
|
7726
|
+
"npm-lib, internal-lib, react-lib, react-internal-lib, node-function-app: scaffold the slice skeleton only, with no sample code or spec"
|
|
7710
7727
|
).option(
|
|
7711
7728
|
"--lib <name>",
|
|
7712
7729
|
"python-vendor only: the internal Python library (libs/<name>) to vendor into <name>"
|