@mnci/nx-python-pip 0.1.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 +120 -0
- package/dist/executors/build/executor.d.ts +25 -0
- package/dist/executors/build/executor.d.ts.map +1 -0
- package/dist/executors/build/executor.js +81 -0
- package/dist/executors/build/executor.js.map +1 -0
- package/dist/executors/build/schema.json +10 -0
- package/dist/executors/lint/executor.d.ts +20 -0
- package/dist/executors/lint/executor.d.ts.map +1 -0
- package/dist/executors/lint/executor.js +26 -0
- package/dist/executors/lint/executor.js.map +1 -0
- package/dist/executors/lint/schema.json +9 -0
- package/dist/executors/publish/executor.d.ts +30 -0
- package/dist/executors/publish/executor.d.ts.map +1 -0
- package/dist/executors/publish/executor.js +42 -0
- package/dist/executors/publish/executor.js.map +1 -0
- package/dist/executors/publish/schema.json +16 -0
- package/dist/executors/test/executor.d.ts +26 -0
- package/dist/executors/test/executor.d.ts.map +1 -0
- package/dist/executors/test/executor.js +38 -0
- package/dist/executors/test/executor.js.map +1 -0
- package/dist/executors/test/schema.json +15 -0
- package/dist/generators/application/generator.d.ts +20 -0
- package/dist/generators/application/generator.d.ts.map +1 -0
- package/dist/generators/application/generator.js +29 -0
- package/dist/generators/application/generator.js.map +1 -0
- package/dist/generators/application/schema.json +22 -0
- package/dist/generators/functionApplication/generator.d.ts +21 -0
- package/dist/generators/functionApplication/generator.d.ts.map +1 -0
- package/dist/generators/functionApplication/generator.js +43 -0
- package/dist/generators/functionApplication/generator.js.map +1 -0
- package/dist/generators/functionApplication/schema.json +22 -0
- package/dist/generators/internalLibrary/generator.d.ts +20 -0
- package/dist/generators/internalLibrary/generator.d.ts.map +1 -0
- package/dist/generators/internalLibrary/generator.js +39 -0
- package/dist/generators/internalLibrary/generator.js.map +1 -0
- package/dist/generators/internalLibrary/schema.json +22 -0
- package/dist/generators/library/generator.d.ts +23 -0
- package/dist/generators/library/generator.d.ts.map +1 -0
- package/dist/generators/library/generator.js +33 -0
- package/dist/generators/library/generator.js.map +1 -0
- package/dist/generators/library/schema.json +22 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/azureFunctionApp.d.ts +53 -0
- package/dist/internal/azureFunctionApp.d.ts.map +1 -0
- package/dist/internal/azureFunctionApp.js +89 -0
- package/dist/internal/azureFunctionApp.js.map +1 -0
- package/dist/internal/executorContext.d.ts +17 -0
- package/dist/internal/executorContext.d.ts.map +1 -0
- package/dist/internal/executorContext.js +26 -0
- package/dist/internal/executorContext.js.map +1 -0
- package/dist/internal/generateProject.d.ts +43 -0
- package/dist/internal/generateProject.d.ts.map +1 -0
- package/dist/internal/generateProject.js +58 -0
- package/dist/internal/generateProject.js.map +1 -0
- package/dist/internal/pythonProject.d.ts +57 -0
- package/dist/internal/pythonProject.d.ts.map +1 -0
- package/dist/internal/pythonProject.js +94 -0
- package/dist/internal/pythonProject.js.map +1 -0
- package/dist/internal/vendor.d.ts +42 -0
- package/dist/internal/vendor.d.ts.map +1 -0
- package/dist/internal/vendor.js +64 -0
- package/dist/internal/vendor.js.map +1 -0
- package/dist/release/versionActions.d.ts +107 -0
- package/dist/release/versionActions.d.ts.map +1 -0
- package/dist/release/versionActions.js +136 -0
- package/dist/release/versionActions.js.map +1 -0
- package/executors.json +25 -0
- package/generators.json +25 -0
- package/package.json +63 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = functionAppGenerator;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const azureFunctionApp_1 = require("../../internal/azureFunctionApp");
|
|
6
|
+
const pythonProject_1 = require("../../internal/pythonProject");
|
|
7
|
+
/**
|
|
8
|
+
* Generates a Python Azure Function app (v2 programming model): `function_app.py`
|
|
9
|
+
* + `host.json` + `requirements.txt` + a tested pure helper module.
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* No `pyproject.toml`/`build` target: the deployable is the **source tree**
|
|
13
|
+
* (Azure's Python worker installs `requirements.txt` and runs
|
|
14
|
+
* `function_app.py` directly — Oryx build at deploy time, no wheel), so this
|
|
15
|
+
* generator writes no build system at all. `func` CLI is not needed to
|
|
16
|
+
* generate — only for local `func start`.
|
|
17
|
+
*
|
|
18
|
+
* @param tree - The Nx virtual file system.
|
|
19
|
+
* @param options - The project name and directory.
|
|
20
|
+
* @returns A promise that resolves once generated files are formatted.
|
|
21
|
+
* @throws Never - pure Tree writes.
|
|
22
|
+
* @typeParam None - this function has no generic type parameters.
|
|
23
|
+
*/
|
|
24
|
+
async function functionAppGenerator(tree, options) {
|
|
25
|
+
const root = options.directory ?? `apps/${options.name}`;
|
|
26
|
+
const moduleDirectory = (0, pythonProject_1.pythonModuleDirectory)(options.name);
|
|
27
|
+
(0, devkit_1.addProjectConfiguration)(tree, options.name, {
|
|
28
|
+
root,
|
|
29
|
+
projectType: 'application',
|
|
30
|
+
sourceRoot: root,
|
|
31
|
+
targets: {
|
|
32
|
+
lint: { executor: '@mnci/nx-python-pip:lint', options: {} },
|
|
33
|
+
test: { executor: '@mnci/nx-python-pip:test', options: { installEditable: false } },
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
tree.write(`${root}/function_app.py`, (0, azureFunctionApp_1.pythonFunctionAppMain)(moduleDirectory));
|
|
37
|
+
tree.write(`${root}/host.json`, azureFunctionApp_1.PYTHON_FUNCTION_APP_HOST_JSON);
|
|
38
|
+
tree.write(`${root}/requirements.txt`, azureFunctionApp_1.PYTHON_FUNCTION_APP_REQUIREMENTS);
|
|
39
|
+
tree.write(`${root}/${moduleDirectory}/greeting.py`, azureFunctionApp_1.PYTHON_FUNCTION_APP_GREETING);
|
|
40
|
+
tree.write(`${root}/tests/test_greeting.py`, (0, azureFunctionApp_1.pythonFunctionAppGreetingTest)(moduleDirectory));
|
|
41
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../src/generators/functionApplication/generator.ts"],"names":[],"mappings":";;;AAAA,uCAA4E;AAC5E,sEAMwC;AACxC,gEAAoE;AAGpE;;;;;;;;;;;;;;;;GAgBG;AACY,KAAK,+BAAgC,IAAU,EAAE,OAAmC;IACjG,MAAM,IAAI,GAAG,OAAO,CAAC,SAAS,IAAI,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAA;IACxD,MAAM,eAAe,GAAG,IAAA,qCAAqB,EAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAE3D,IAAA,gCAAuB,EAAC,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE;QAC1C,IAAI;QACJ,WAAW,EAAE,aAAa;QAC1B,UAAU,EAAG,IAAI;QACjB,OAAO,EAAM;YACX,IAAI,EAAE,EAAE,QAAQ,EAAE,0BAA0B,EAAE,OAAO,EAAE,EAAE,EAAE;YAC3D,IAAI,EAAE,EAAE,QAAQ,EAAE,0BAA0B,EAAE,OAAO,EAAE,EAAE,eAAe,EAAE,KAAK,EAAE,EAAE;SACpF;KACF,CAAC,CAAA;IAEF,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,kBAAkB,EAAE,IAAA,wCAAqB,EAAC,eAAe,CAAC,CAAC,CAAA;IAC7E,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,YAAY,EAAE,gDAA6B,CAAC,CAAA;IAC9D,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,mBAAmB,EAAE,mDAAgC,CAAC,CAAA;IACxE,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,eAAe,cAAc,EAAE,+CAA4B,CAAC,CAAA;IAClF,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,yBAAyB,EAAE,IAAA,gDAA6B,EAAC,eAAe,CAAC,CAAC,CAAA;IAC5F,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAA;AACzB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"cli": "nx",
|
|
4
|
+
"$id": "MnciNxPythonPipFunctionApplication",
|
|
5
|
+
"title": "Create a Python Azure Function app (v2 programming model)",
|
|
6
|
+
"description": "Hand-authors an Azure Functions v2 Python app: function_app.py + host.json + requirements.txt + a tested pure helper. No pyproject.toml/wheel build — the deployable is the source tree, not a wheel.",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"name": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "The project name.",
|
|
12
|
+
"$default": { "$source": "argv", "index": 0 },
|
|
13
|
+
"x-prompt": "What name would you like to use?",
|
|
14
|
+
"pattern": "^[a-zA-Z][^:]*$"
|
|
15
|
+
},
|
|
16
|
+
"directory": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"description": "Workspace-relative directory for the project (defaults to apps/<name>)."
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"required": ["name"]
|
|
22
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
|
2
|
+
import type { InternalLibraryGeneratorSchema } from './schema.d';
|
|
3
|
+
/**
|
|
4
|
+
* Generates a private, never-published Python library: `pyproject.toml` +
|
|
5
|
+
* `project.json` (lint/test only) + a sample module and pytest.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* No `build` target: an internal lib is never built or packaged on its own —
|
|
9
|
+
* a consumer vendors its module directly into its own wheel at build time by
|
|
10
|
+
* hand-adding a `[tool.mnci-python-pip] vendor = ["<this-lib>"]` entry to its
|
|
11
|
+
* own `pyproject.toml` (see the `build` executor).
|
|
12
|
+
*
|
|
13
|
+
* @param tree - The Nx virtual file system.
|
|
14
|
+
* @param options - The project name and directory.
|
|
15
|
+
* @returns A promise that resolves once generated files are formatted.
|
|
16
|
+
* @throws Never - pure Tree writes.
|
|
17
|
+
* @typeParam None - this function has no generic type parameters.
|
|
18
|
+
*/
|
|
19
|
+
export default function internalLibraryGenerator(tree: Tree, options: InternalLibraryGeneratorSchema): Promise<void>;
|
|
20
|
+
//# sourceMappingURL=generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/generators/internalLibrary/generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,KAAK,IAAI,EAAE,MAAM,YAAY,CAAA;AAE5E,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,YAAY,CAAA;AAEhE;;;;;;;;;;;;;;;GAeG;AACH,wBAA8B,wBAAwB,CAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,8BAA8B,GAAG,OAAO,CAAC,IAAI,CAAC,CAkB1H"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = internalLibraryGenerator;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const pythonProject_1 = require("../../internal/pythonProject");
|
|
6
|
+
/**
|
|
7
|
+
* Generates a private, never-published Python library: `pyproject.toml` +
|
|
8
|
+
* `project.json` (lint/test only) + a sample module and pytest.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* No `build` target: an internal lib is never built or packaged on its own —
|
|
12
|
+
* a consumer vendors its module directly into its own wheel at build time by
|
|
13
|
+
* hand-adding a `[tool.mnci-python-pip] vendor = ["<this-lib>"]` entry to its
|
|
14
|
+
* own `pyproject.toml` (see the `build` executor).
|
|
15
|
+
*
|
|
16
|
+
* @param tree - The Nx virtual file system.
|
|
17
|
+
* @param options - The project name and directory.
|
|
18
|
+
* @returns A promise that resolves once generated files are formatted.
|
|
19
|
+
* @throws Never - pure Tree writes.
|
|
20
|
+
* @typeParam None - this function has no generic type parameters.
|
|
21
|
+
*/
|
|
22
|
+
async function internalLibraryGenerator(tree, options) {
|
|
23
|
+
const root = options.directory ?? `libs/${options.name}`;
|
|
24
|
+
const moduleDirectory = (0, pythonProject_1.pythonModuleDirectory)(options.name);
|
|
25
|
+
(0, devkit_1.addProjectConfiguration)(tree, options.name, {
|
|
26
|
+
root,
|
|
27
|
+
projectType: 'library',
|
|
28
|
+
sourceRoot: root,
|
|
29
|
+
targets: {
|
|
30
|
+
lint: { executor: '@mnci/nx-python-pip:lint', options: {} },
|
|
31
|
+
test: { executor: '@mnci/nx-python-pip:test', options: {} },
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
tree.write(`${root}/pyproject.toml`, (0, pythonProject_1.pythonPyprojectToml)(options.name, moduleDirectory));
|
|
35
|
+
tree.write(`${root}/${moduleDirectory}/__init__.py`, (0, pythonProject_1.pythonSampleModule)(moduleDirectory));
|
|
36
|
+
tree.write(`${root}/tests/test_${moduleDirectory}.py`, (0, pythonProject_1.pythonSampleTest)(moduleDirectory));
|
|
37
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../src/generators/internalLibrary/generator.ts"],"names":[],"mappings":";;;AAAA,uCAA4E;AAC5E,gEAA+H;AAG/H;;;;;;;;;;;;;;;GAeG;AACY,KAAK,mCAAoC,IAAU,EAAE,OAAuC;IACzG,MAAM,IAAI,GAAG,OAAO,CAAC,SAAS,IAAI,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAA;IACxD,MAAM,eAAe,GAAG,IAAA,qCAAqB,EAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAE3D,IAAA,gCAAuB,EAAC,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE;QAC1C,IAAI;QACJ,WAAW,EAAE,SAAS;QACtB,UAAU,EAAG,IAAI;QACjB,OAAO,EAAM;YACX,IAAI,EAAE,EAAE,QAAQ,EAAE,0BAA0B,EAAE,OAAO,EAAE,EAAE,EAAE;YAC3D,IAAI,EAAE,EAAE,QAAQ,EAAE,0BAA0B,EAAE,OAAO,EAAE,EAAE,EAAE;SAC5D;KACF,CAAC,CAAA;IAEF,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,iBAAiB,EAAE,IAAA,mCAAmB,EAAC,OAAO,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC,CAAA;IACxF,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,eAAe,cAAc,EAAE,IAAA,kCAAkB,EAAC,eAAe,CAAC,CAAC,CAAA;IACzF,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,eAAe,eAAe,KAAK,EAAE,IAAA,gCAAgB,EAAC,eAAe,CAAC,CAAC,CAAA;IACzF,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAA;AACzB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"cli": "nx",
|
|
4
|
+
"$id": "MnciNxPythonPipInternalLibrary",
|
|
5
|
+
"title": "Create a private, never-published Python library",
|
|
6
|
+
"description": "Hand-authors a private Python library: pyproject.toml + project.json (lint/test only, no build/publish target) + a sample module and pytest. Consumers vendor its module into their own wheel at build time via [tool.mnci-python-pip] vendor = [...].",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"name": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "The project name.",
|
|
12
|
+
"$default": { "$source": "argv", "index": 0 },
|
|
13
|
+
"x-prompt": "What name would you like to use?",
|
|
14
|
+
"pattern": "^[a-zA-Z][^:]*$"
|
|
15
|
+
},
|
|
16
|
+
"directory": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"description": "Workspace-relative directory for the project (defaults to libs/<name>)."
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"required": ["name"]
|
|
22
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Tree } from '@nx/devkit';
|
|
2
|
+
import type { LibraryGeneratorSchema } from './schema.d';
|
|
3
|
+
/**
|
|
4
|
+
* Generates a publishable pip-native Python library: `pyproject.toml` +
|
|
5
|
+
* `project.json` (lint/test/build/`nx-release-publish`) + a sample module
|
|
6
|
+
* and pytest.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* `nx-release-publish` runs `python -m twine upload` (the `publish`
|
|
10
|
+
* executor); the project's own `release.version.versionActions` points at
|
|
11
|
+
* this package's hand-written `PythonVersionActions` implementation, so
|
|
12
|
+
* `nx release` reads/writes `pyproject.toml` correctly regardless of
|
|
13
|
+
* whatever default the consuming workspace's `nx.json` configures (npm's
|
|
14
|
+
* default, typically).
|
|
15
|
+
*
|
|
16
|
+
* @param tree - The Nx virtual file system.
|
|
17
|
+
* @param options - The project name and directory.
|
|
18
|
+
* @returns A promise that resolves once generated files are formatted.
|
|
19
|
+
* @throws Never - pure Tree writes.
|
|
20
|
+
* @typeParam None - this function has no generic type parameters.
|
|
21
|
+
*/
|
|
22
|
+
export default function libraryGenerator(tree: Tree, options: LibraryGeneratorSchema): Promise<void>;
|
|
23
|
+
//# sourceMappingURL=generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/generators/library/generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAEtC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAExD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAA8B,gBAAgB,CAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAQ1G"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = libraryGenerator;
|
|
4
|
+
const generateProject_1 = require("../../internal/generateProject");
|
|
5
|
+
/**
|
|
6
|
+
* Generates a publishable pip-native Python library: `pyproject.toml` +
|
|
7
|
+
* `project.json` (lint/test/build/`nx-release-publish`) + a sample module
|
|
8
|
+
* and pytest.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* `nx-release-publish` runs `python -m twine upload` (the `publish`
|
|
12
|
+
* executor); the project's own `release.version.versionActions` points at
|
|
13
|
+
* this package's hand-written `PythonVersionActions` implementation, so
|
|
14
|
+
* `nx release` reads/writes `pyproject.toml` correctly regardless of
|
|
15
|
+
* whatever default the consuming workspace's `nx.json` configures (npm's
|
|
16
|
+
* default, typically).
|
|
17
|
+
*
|
|
18
|
+
* @param tree - The Nx virtual file system.
|
|
19
|
+
* @param options - The project name and directory.
|
|
20
|
+
* @returns A promise that resolves once generated files are formatted.
|
|
21
|
+
* @throws Never - pure Tree writes.
|
|
22
|
+
* @typeParam None - this function has no generic type parameters.
|
|
23
|
+
*/
|
|
24
|
+
async function libraryGenerator(tree, options) {
|
|
25
|
+
(0, generateProject_1.generateBuildableProject)(tree, {
|
|
26
|
+
name: options.name,
|
|
27
|
+
directory: options.directory ?? `libs/${options.name}`,
|
|
28
|
+
projectType: 'library',
|
|
29
|
+
publishable: true,
|
|
30
|
+
});
|
|
31
|
+
await (0, generateProject_1.formatFiles)(tree);
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../src/generators/library/generator.ts"],"names":[],"mappings":";;;AACA,oEAAsF;AAGtF;;;;;;;;;;;;;;;;;;GAkBG;AACY,KAAK,2BAA4B,IAAU,EAAE,OAA+B;IACzF,IAAA,0CAAwB,EAAC,IAAI,EAAE;QAC7B,IAAI,EAAS,OAAO,CAAC,IAAI;QACzB,SAAS,EAAI,OAAO,CAAC,SAAS,IAAI,QAAQ,OAAO,CAAC,IAAI,EAAE;QACxD,WAAW,EAAE,SAAS;QACtB,WAAW,EAAE,IAAI;KAClB,CAAC,CAAA;IACF,MAAM,IAAA,6BAAW,EAAC,IAAI,CAAC,CAAA;AACzB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"cli": "nx",
|
|
4
|
+
"$id": "MnciNxPythonPipLibrary",
|
|
5
|
+
"title": "Create a publishable Python library",
|
|
6
|
+
"description": "Hand-authors a pip-native, publishable Python library: pyproject.toml (hatchling) + project.json (lint/test/build/nx-release-publish targets, a project-level versionActions override) + a sample module and pytest.",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"name": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "The project name.",
|
|
12
|
+
"$default": { "$source": "argv", "index": 0 },
|
|
13
|
+
"x-prompt": "What name would you like to use?",
|
|
14
|
+
"pattern": "^[a-zA-Z][^:]*$"
|
|
15
|
+
},
|
|
16
|
+
"directory": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"description": "Workspace-relative directory for the project (defaults to libs/<name>)."
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"required": ["name"]
|
|
22
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Azure Functions v2 entry written into a generated Python function app.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* The Python v2 programming model: a module-level `func.FunctionApp()` with
|
|
6
|
+
* decorated routes. The handler is thin — the testable logic lives in the
|
|
7
|
+
* module's `greeting.py` (imported here), so pytest needs no `azure-functions`
|
|
8
|
+
* install. Anonymous auth keeps the sample runnable locally with `func start`.
|
|
9
|
+
*
|
|
10
|
+
* @param moduleDirectory - The app's Python module directory (import root).
|
|
11
|
+
* @returns The `function_app.py` contents.
|
|
12
|
+
* @throws Never - pure string build.
|
|
13
|
+
* @typeParam None - this function has no generic type parameters.
|
|
14
|
+
*/
|
|
15
|
+
export declare function pythonFunctionAppMain(moduleDirectory: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* The `host.json` written into a generated Python function app.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* The v4 extension bundle is what the Functions host uses to resolve bindings;
|
|
21
|
+
* `version: 2.0` is the runtime schema. Deliberately minimal.
|
|
22
|
+
*/
|
|
23
|
+
export declare const PYTHON_FUNCTION_APP_HOST_JSON = "{\n \"version\": \"2.0\",\n \"extensionBundle\": {\n \"id\": \"Microsoft.Azure.Functions.ExtensionBundle\",\n \"version\": \"[4.*, 5.0.0)\"\n }\n}\n";
|
|
24
|
+
/**
|
|
25
|
+
* The `requirements.txt` written into a generated Python function app.
|
|
26
|
+
*
|
|
27
|
+
* @remarks
|
|
28
|
+
* Azure's Python worker installs these at deploy time (Oryx build). Only the
|
|
29
|
+
* SDK is needed for the sample; app deps are added here as the app grows.
|
|
30
|
+
*/
|
|
31
|
+
export declare const PYTHON_FUNCTION_APP_REQUIREMENTS = "azure-functions\n";
|
|
32
|
+
/**
|
|
33
|
+
* A sample pure helper written into a Python function app's module.
|
|
34
|
+
*
|
|
35
|
+
* @remarks
|
|
36
|
+
* Gives the app a genuinely testable unit (the HTTP handler would need the
|
|
37
|
+
* Functions runtime), so pytest has a real passing test out of the box.
|
|
38
|
+
*/
|
|
39
|
+
export declare const PYTHON_FUNCTION_APP_GREETING = "def build_greeting(name: str) -> str:\n \"\"\"Build the greeting returned by the sample HTTP function.\"\"\"\n return \"Hello, \" + name + \"!\"\n";
|
|
40
|
+
/**
|
|
41
|
+
* The sample pytest proving the Python function app's test target runs.
|
|
42
|
+
*
|
|
43
|
+
* @remarks
|
|
44
|
+
* Imports only the pure helper (no `azure-functions`), so it passes with
|
|
45
|
+
* plain `pytest` — no install step needed.
|
|
46
|
+
*
|
|
47
|
+
* @param moduleDirectory - The app's Python module directory (import root).
|
|
48
|
+
* @returns The `tests/test_greeting.py` contents.
|
|
49
|
+
* @throws Never - pure string build.
|
|
50
|
+
* @typeParam None - this function has no generic type parameters.
|
|
51
|
+
*/
|
|
52
|
+
export declare function pythonFunctionAppGreetingTest(moduleDirectory: string): string;
|
|
53
|
+
//# sourceMappingURL=azureFunctionApp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"azureFunctionApp.d.ts","sourceRoot":"","sources":["../../src/internal/azureFunctionApp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CAAE,eAAe,EAAE,MAAM,GAAG,MAAM,CAatE;AAED;;;;;;GAMG;AACH,eAAO,MAAM,6BAA6B,kKAOzC,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,gCAAgC,sBAC5C,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,6JAGxC,CAAA;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,6BAA6B,CAAE,eAAe,EAAE,MAAM,GAAG,MAAM,CAO9E"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PYTHON_FUNCTION_APP_GREETING = exports.PYTHON_FUNCTION_APP_REQUIREMENTS = exports.PYTHON_FUNCTION_APP_HOST_JSON = void 0;
|
|
4
|
+
exports.pythonFunctionAppMain = pythonFunctionAppMain;
|
|
5
|
+
exports.pythonFunctionAppGreetingTest = pythonFunctionAppGreetingTest;
|
|
6
|
+
/**
|
|
7
|
+
* The Azure Functions v2 entry written into a generated Python function app.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* The Python v2 programming model: a module-level `func.FunctionApp()` with
|
|
11
|
+
* decorated routes. The handler is thin — the testable logic lives in the
|
|
12
|
+
* module's `greeting.py` (imported here), so pytest needs no `azure-functions`
|
|
13
|
+
* install. Anonymous auth keeps the sample runnable locally with `func start`.
|
|
14
|
+
*
|
|
15
|
+
* @param moduleDirectory - The app's Python module directory (import root).
|
|
16
|
+
* @returns The `function_app.py` contents.
|
|
17
|
+
* @throws Never - pure string build.
|
|
18
|
+
* @typeParam None - this function has no generic type parameters.
|
|
19
|
+
*/
|
|
20
|
+
function pythonFunctionAppMain(moduleDirectory) {
|
|
21
|
+
return `import azure.functions as func
|
|
22
|
+
|
|
23
|
+
from ${moduleDirectory}.greeting import build_greeting
|
|
24
|
+
|
|
25
|
+
app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@app.route(route="hello")
|
|
29
|
+
def hello(req: func.HttpRequest) -> func.HttpResponse:
|
|
30
|
+
name = req.params.get("name", "world")
|
|
31
|
+
return func.HttpResponse(build_greeting(name))
|
|
32
|
+
`;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The `host.json` written into a generated Python function app.
|
|
36
|
+
*
|
|
37
|
+
* @remarks
|
|
38
|
+
* The v4 extension bundle is what the Functions host uses to resolve bindings;
|
|
39
|
+
* `version: 2.0` is the runtime schema. Deliberately minimal.
|
|
40
|
+
*/
|
|
41
|
+
exports.PYTHON_FUNCTION_APP_HOST_JSON = `{
|
|
42
|
+
"version": "2.0",
|
|
43
|
+
"extensionBundle": {
|
|
44
|
+
"id": "Microsoft.Azure.Functions.ExtensionBundle",
|
|
45
|
+
"version": "[4.*, 5.0.0)"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
`;
|
|
49
|
+
/**
|
|
50
|
+
* The `requirements.txt` written into a generated Python function app.
|
|
51
|
+
*
|
|
52
|
+
* @remarks
|
|
53
|
+
* Azure's Python worker installs these at deploy time (Oryx build). Only the
|
|
54
|
+
* SDK is needed for the sample; app deps are added here as the app grows.
|
|
55
|
+
*/
|
|
56
|
+
exports.PYTHON_FUNCTION_APP_REQUIREMENTS = `azure-functions
|
|
57
|
+
`;
|
|
58
|
+
/**
|
|
59
|
+
* A sample pure helper written into a Python function app's module.
|
|
60
|
+
*
|
|
61
|
+
* @remarks
|
|
62
|
+
* Gives the app a genuinely testable unit (the HTTP handler would need the
|
|
63
|
+
* Functions runtime), so pytest has a real passing test out of the box.
|
|
64
|
+
*/
|
|
65
|
+
exports.PYTHON_FUNCTION_APP_GREETING = `def build_greeting(name: str) -> str:
|
|
66
|
+
"""Build the greeting returned by the sample HTTP function."""
|
|
67
|
+
return "Hello, " + name + "!"
|
|
68
|
+
`;
|
|
69
|
+
/**
|
|
70
|
+
* The sample pytest proving the Python function app's test target runs.
|
|
71
|
+
*
|
|
72
|
+
* @remarks
|
|
73
|
+
* Imports only the pure helper (no `azure-functions`), so it passes with
|
|
74
|
+
* plain `pytest` — no install step needed.
|
|
75
|
+
*
|
|
76
|
+
* @param moduleDirectory - The app's Python module directory (import root).
|
|
77
|
+
* @returns The `tests/test_greeting.py` contents.
|
|
78
|
+
* @throws Never - pure string build.
|
|
79
|
+
* @typeParam None - this function has no generic type parameters.
|
|
80
|
+
*/
|
|
81
|
+
function pythonFunctionAppGreetingTest(moduleDirectory) {
|
|
82
|
+
return `from ${moduleDirectory}.greeting import build_greeting
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def test_build_greeting() -> None:
|
|
86
|
+
assert build_greeting("world") == "Hello, world!"
|
|
87
|
+
`;
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=azureFunctionApp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"azureFunctionApp.js","sourceRoot":"","sources":["../../src/internal/azureFunctionApp.ts"],"names":[],"mappings":";;;;;AAAA;;;;;;;;;;;;;GAaG;AACH,+BAAuC,eAAuB;IAC5D,OAAO;;OAEF,eAAe;;;;;;;;;CASrB,CAAA;AACD,CAAC;AAED;;;;;;GAMG;AACU,QAAA,6BAA6B,GAAG;;;;;;;CAO5C,CAAA;AAED;;;;;;GAMG;AACU,QAAA,gCAAgC,GAAG;CAC/C,CAAA;AAED;;;;;;GAMG;AACU,QAAA,4BAA4B,GAAG;;;CAG3C,CAAA;AAED;;;;;;;;;;;GAWG;AACH,uCAA+C,eAAuB;IACpE,OAAO,QAAQ,eAAe;;;;;CAK/B,CAAA;AACD,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ExecutorContext } from '@nx/devkit';
|
|
2
|
+
/**
|
|
3
|
+
* Resolves the running project's workspace-relative root directory from an
|
|
4
|
+
* executor context.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Shared by every executor in this package, so each one gets the project
|
|
8
|
+
* root (to build the `cwd` it runs pip/pytest/ruff/twine in) the same way.
|
|
9
|
+
*
|
|
10
|
+
* @param context - The Nx executor context.
|
|
11
|
+
* @returns The workspace-relative project root.
|
|
12
|
+
* @throws Error when the context has no resolvable project (should be
|
|
13
|
+
* unreachable — Nx always sets `projectName` for a target invocation).
|
|
14
|
+
* @typeParam None - this function has no generic type parameters.
|
|
15
|
+
*/
|
|
16
|
+
export declare function projectRootFrom(context: ExecutorContext): string;
|
|
17
|
+
//# sourceMappingURL=executorContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executorContext.d.ts","sourceRoot":"","sources":["../../src/internal/executorContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEjD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAE,OAAO,EAAE,eAAe,GAAG,MAAM,CAOjE"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.projectRootFrom = projectRootFrom;
|
|
4
|
+
/**
|
|
5
|
+
* Resolves the running project's workspace-relative root directory from an
|
|
6
|
+
* executor context.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* Shared by every executor in this package, so each one gets the project
|
|
10
|
+
* root (to build the `cwd` it runs pip/pytest/ruff/twine in) the same way.
|
|
11
|
+
*
|
|
12
|
+
* @param context - The Nx executor context.
|
|
13
|
+
* @returns The workspace-relative project root.
|
|
14
|
+
* @throws Error when the context has no resolvable project (should be
|
|
15
|
+
* unreachable — Nx always sets `projectName` for a target invocation).
|
|
16
|
+
* @typeParam None - this function has no generic type parameters.
|
|
17
|
+
*/
|
|
18
|
+
function projectRootFrom(context) {
|
|
19
|
+
const projectName = context.projectName;
|
|
20
|
+
const root = projectName ? context.projectsConfigurations?.projects[projectName]?.root : undefined;
|
|
21
|
+
if (!root) {
|
|
22
|
+
throw new Error('Could not resolve the project root from the executor context.');
|
|
23
|
+
}
|
|
24
|
+
return root;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=executorContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executorContext.js","sourceRoot":"","sources":["../../src/internal/executorContext.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;GAaG;AACH,yBAAiC,OAAwB;IACvD,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAA;IACvC,MAAM,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,SAAS,CAAA;IAClG,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAA;IAClF,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
|
2
|
+
/**
|
|
3
|
+
* Options shared by every buildable-project generator (`application`, `library`).
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* `publishable` is the only thing that differs between the `application` and
|
|
7
|
+
* `library` generators — see {@link generateBuildableProject}.
|
|
8
|
+
*
|
|
9
|
+
* @typeParam None - this interface has no generic type parameters.
|
|
10
|
+
*/
|
|
11
|
+
export interface BuildableProjectOptions {
|
|
12
|
+
/** The project name. */
|
|
13
|
+
name: string;
|
|
14
|
+
/** Workspace-relative directory. */
|
|
15
|
+
directory: string;
|
|
16
|
+
/** `application` (apps) or `library` (libs/python-packages). */
|
|
17
|
+
projectType: 'application' | 'library';
|
|
18
|
+
/** Adds a `nx-release-publish` target + a project-level `versionActions` override. */
|
|
19
|
+
publishable?: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Writes a buildable Python project: `pyproject.toml` + `project.json`
|
|
23
|
+
* (lint/test/build[/publish]) + a sample module and pytest.
|
|
24
|
+
*
|
|
25
|
+
* @remarks
|
|
26
|
+
* Shared by the `application` and `library` generators — the only difference
|
|
27
|
+
* between an app and a publishable lib is whether `publishable` adds the
|
|
28
|
+
* `nx-release-publish` target and the project-level
|
|
29
|
+
* `release.version.versionActions` override pointing at this package's own
|
|
30
|
+
* hand-written `PythonVersionActions` implementation
|
|
31
|
+
* (`@mnci/nx-python-pip/release/version-actions`), which wins over any
|
|
32
|
+
* workspace-level default for just this project — the same mechanism
|
|
33
|
+
* `@nxlv/python`'s own `--publishable` flag used.
|
|
34
|
+
*
|
|
35
|
+
* @param tree - The Nx virtual file system.
|
|
36
|
+
* @param options - The project name, directory, type and publishability.
|
|
37
|
+
* @returns Nothing.
|
|
38
|
+
* @throws Never - pure Tree writes.
|
|
39
|
+
* @typeParam None - this function has no generic type parameters.
|
|
40
|
+
*/
|
|
41
|
+
export declare function generateBuildableProject(tree: Tree, options: BuildableProjectOptions): void;
|
|
42
|
+
export { formatFiles } from '@nx/devkit';
|
|
43
|
+
//# sourceMappingURL=generateProject.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateProject.d.ts","sourceRoot":"","sources":["../../src/internal/generateProject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsD,KAAK,IAAI,EAAE,MAAM,YAAY,CAAA;AAU1F;;;;;;;;GAQG;AACH,MAAM,WAAW,uBAAuB;IACtC,wBAAwB;IACxB,IAAI,EAAU,MAAM,CAAA;IACpB,oCAAoC;IACpC,SAAS,EAAK,MAAM,CAAA;IACpB,gEAAgE;IAChE,WAAW,EAAG,aAAa,GAAG,SAAS,CAAA;IACvC,sFAAsF;IACtF,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,wBAAwB,CAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,uBAAuB,GAAG,IAAI,CA2B5F;AAED,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatFiles = void 0;
|
|
4
|
+
exports.generateBuildableProject = generateBuildableProject;
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const pythonProject_1 = require("./pythonProject");
|
|
7
|
+
/** The `nx-release-publish` target for a publishable Python library (twine). */
|
|
8
|
+
const PUBLISH_TARGET = {
|
|
9
|
+
executor: '@mnci/nx-python-pip:publish',
|
|
10
|
+
dependsOn: ['build'],
|
|
11
|
+
options: {},
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Writes a buildable Python project: `pyproject.toml` + `project.json`
|
|
15
|
+
* (lint/test/build[/publish]) + a sample module and pytest.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* Shared by the `application` and `library` generators — the only difference
|
|
19
|
+
* between an app and a publishable lib is whether `publishable` adds the
|
|
20
|
+
* `nx-release-publish` target and the project-level
|
|
21
|
+
* `release.version.versionActions` override pointing at this package's own
|
|
22
|
+
* hand-written `PythonVersionActions` implementation
|
|
23
|
+
* (`@mnci/nx-python-pip/release/version-actions`), which wins over any
|
|
24
|
+
* workspace-level default for just this project — the same mechanism
|
|
25
|
+
* `@nxlv/python`'s own `--publishable` flag used.
|
|
26
|
+
*
|
|
27
|
+
* @param tree - The Nx virtual file system.
|
|
28
|
+
* @param options - The project name, directory, type and publishability.
|
|
29
|
+
* @returns Nothing.
|
|
30
|
+
* @throws Never - pure Tree writes.
|
|
31
|
+
* @typeParam None - this function has no generic type parameters.
|
|
32
|
+
*/
|
|
33
|
+
function generateBuildableProject(tree, options) {
|
|
34
|
+
const moduleDirectory = (0, pythonProject_1.pythonModuleDirectory)(options.name);
|
|
35
|
+
const root = options.directory;
|
|
36
|
+
const targets = {
|
|
37
|
+
lint: { executor: '@mnci/nx-python-pip:lint', options: {} },
|
|
38
|
+
test: { executor: '@mnci/nx-python-pip:test', options: {} },
|
|
39
|
+
build: { executor: '@mnci/nx-python-pip:build', outputs: ['{projectRoot}/dist'], options: {} },
|
|
40
|
+
};
|
|
41
|
+
const project = {
|
|
42
|
+
root,
|
|
43
|
+
projectType: options.projectType,
|
|
44
|
+
sourceRoot: root,
|
|
45
|
+
targets,
|
|
46
|
+
};
|
|
47
|
+
if (options.publishable) {
|
|
48
|
+
targets['nx-release-publish'] = PUBLISH_TARGET;
|
|
49
|
+
project.release = { version: { versionActions: '@mnci/nx-python-pip/release/version-actions' } };
|
|
50
|
+
}
|
|
51
|
+
(0, devkit_1.addProjectConfiguration)(tree, options.name, project);
|
|
52
|
+
tree.write(`${root}/pyproject.toml`, (0, pythonProject_1.pythonPyprojectToml)(options.name, moduleDirectory));
|
|
53
|
+
tree.write(`${root}/${moduleDirectory}/__init__.py`, (0, pythonProject_1.pythonSampleModule)(moduleDirectory));
|
|
54
|
+
tree.write(`${root}/tests/test_${moduleDirectory}.py`, (0, pythonProject_1.pythonSampleTest)(moduleDirectory));
|
|
55
|
+
}
|
|
56
|
+
var devkit_2 = require("@nx/devkit");
|
|
57
|
+
Object.defineProperty(exports, "formatFiles", { enumerable: true, get: function () { return devkit_2.formatFiles; } });
|
|
58
|
+
//# sourceMappingURL=generateProject.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateProject.js","sourceRoot":"","sources":["../../src/internal/generateProject.ts"],"names":[],"mappings":";;;;AAAA,uCAA0F;AAC1F,mDAAkH;AAElH,gFAAgF;AAChF,MAAM,cAAc,GAAG;IACrB,QAAQ,EAAG,6BAA6B;IACxC,SAAS,EAAE,CAAC,OAAO,CAAC;IACpB,OAAO,EAAI,EAAE;CACd,CAAA;AAsBD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,kCAA0C,IAAU,EAAE,OAAgC;IACpF,MAAM,eAAe,GAAG,IAAA,qCAAqB,EAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAC3D,MAAM,IAAI,GAAG,OAAO,CAAC,SAAS,CAAA;IAE9B,MAAM,OAAO,GAAoC;QAC/C,IAAI,EAAG,EAAE,QAAQ,EAAE,0BAA0B,EAAE,OAAO,EAAE,EAAE,EAAE;QAC5D,IAAI,EAAG,EAAE,QAAQ,EAAE,0BAA0B,EAAE,OAAO,EAAE,EAAE,EAAE;QAC5D,KAAK,EAAE,EAAE,QAAQ,EAAE,2BAA2B,EAAE,OAAO,EAAE,CAAC,oBAAoB,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE;KAC/F,CAAA;IAED,MAAM,OAAO,GAAyB;QACpC,IAAI;QACJ,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,UAAU,EAAG,IAAI;QACjB,OAAO;KACR,CAAA;IAED,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;QACxB,OAAO,CAAC,oBAAoB,CAAC,GAAG,cAAc,CAAA;QAC9C,OAAO,CAAC,OAAO,GAAG,EAAE,OAAO,EAAE,EAAE,cAAc,EAAE,6CAA6C,EAAE,EAAE,CAAA;IAClG,CAAC;IAED,IAAA,gCAAuB,EAAC,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IAEpD,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,iBAAiB,EAAE,IAAA,mCAAmB,EAAC,OAAO,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC,CAAA;IACxF,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,eAAe,cAAc,EAAE,IAAA,kCAAkB,EAAC,eAAe,CAAC,CAAC,CAAA;IACzF,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,eAAe,eAAe,KAAK,EAAE,IAAA,gCAAgB,EAAC,eAAe,CAAC,CAAC,CAAA;AAC3F,CAAC;AAED,qCAAwC;AAA/B,qGAAA,WAAW,OAAA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Python project's module directory name, derived from its Nx project name.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Python identifiers cannot contain hyphens, so `my-svc` becomes `my_svc`.
|
|
6
|
+
*
|
|
7
|
+
* @param name - The Nx project name.
|
|
8
|
+
* @returns The module directory's basename (e.g. `my_svc`).
|
|
9
|
+
* @throws Never - pure string mapping.
|
|
10
|
+
* @typeParam None - this function has no generic type parameters.
|
|
11
|
+
*/
|
|
12
|
+
export declare function pythonModuleDirectory(name: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* The `pyproject.toml` written for a buildable Python project (app or lib).
|
|
15
|
+
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* `hatchling` is the PEP 517 backend. The wheel target's `packages` list is
|
|
18
|
+
* explicit (not hatchling's own auto-detection) because the `build` executor
|
|
19
|
+
* patches this exact list when vendoring an internal-lib's module into the
|
|
20
|
+
* wheel (see `parseVendorEntries`). `dependencies` starts empty — external
|
|
21
|
+
* and vendored dependencies alike are wired by hand after generation; no
|
|
22
|
+
* generator wires cross-project Python dependencies automatically.
|
|
23
|
+
*
|
|
24
|
+
* @param name - The project name.
|
|
25
|
+
* @param moduleDirectory - The project's module directory basename.
|
|
26
|
+
* @returns The `pyproject.toml` contents.
|
|
27
|
+
* @throws Never - pure string build.
|
|
28
|
+
* @typeParam None - this function has no generic type parameters.
|
|
29
|
+
*/
|
|
30
|
+
export declare function pythonPyprojectToml(name: string, moduleDirectory: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* A sample pure function written into a generated Python project's module.
|
|
33
|
+
*
|
|
34
|
+
* @remarks
|
|
35
|
+
* Gives every generated project a genuinely testable unit out of the box —
|
|
36
|
+
* paired with {@link pythonSampleTest}.
|
|
37
|
+
*
|
|
38
|
+
* @param moduleDirectory - The project's module directory basename.
|
|
39
|
+
* @returns The `<module>/__init__.py` contents.
|
|
40
|
+
* @throws Never - pure string build.
|
|
41
|
+
* @typeParam None - this function has no generic type parameters.
|
|
42
|
+
*/
|
|
43
|
+
export declare function pythonSampleModule(moduleDirectory: string): string;
|
|
44
|
+
/**
|
|
45
|
+
* The sample pytest proving a generated Python project's `test` target runs.
|
|
46
|
+
*
|
|
47
|
+
* @remarks
|
|
48
|
+
* Imports {@link pythonSampleModule}'s function, so a fresh project's `test`
|
|
49
|
+
* target is green out of the box, no wiring needed.
|
|
50
|
+
*
|
|
51
|
+
* @param moduleDirectory - The project's module directory basename.
|
|
52
|
+
* @returns The `tests/test_<module>.py` contents.
|
|
53
|
+
* @throws Never - pure string build.
|
|
54
|
+
* @typeParam None - this function has no generic type parameters.
|
|
55
|
+
*/
|
|
56
|
+
export declare function pythonSampleTest(moduleDirectory: string): string;
|
|
57
|
+
//# sourceMappingURL=pythonProject.d.ts.map
|