@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.
Files changed (72) hide show
  1. package/README.md +120 -0
  2. package/dist/executors/build/executor.d.ts +25 -0
  3. package/dist/executors/build/executor.d.ts.map +1 -0
  4. package/dist/executors/build/executor.js +81 -0
  5. package/dist/executors/build/executor.js.map +1 -0
  6. package/dist/executors/build/schema.json +10 -0
  7. package/dist/executors/lint/executor.d.ts +20 -0
  8. package/dist/executors/lint/executor.d.ts.map +1 -0
  9. package/dist/executors/lint/executor.js +26 -0
  10. package/dist/executors/lint/executor.js.map +1 -0
  11. package/dist/executors/lint/schema.json +9 -0
  12. package/dist/executors/publish/executor.d.ts +30 -0
  13. package/dist/executors/publish/executor.d.ts.map +1 -0
  14. package/dist/executors/publish/executor.js +42 -0
  15. package/dist/executors/publish/executor.js.map +1 -0
  16. package/dist/executors/publish/schema.json +16 -0
  17. package/dist/executors/test/executor.d.ts +26 -0
  18. package/dist/executors/test/executor.d.ts.map +1 -0
  19. package/dist/executors/test/executor.js +38 -0
  20. package/dist/executors/test/executor.js.map +1 -0
  21. package/dist/executors/test/schema.json +15 -0
  22. package/dist/generators/application/generator.d.ts +20 -0
  23. package/dist/generators/application/generator.d.ts.map +1 -0
  24. package/dist/generators/application/generator.js +29 -0
  25. package/dist/generators/application/generator.js.map +1 -0
  26. package/dist/generators/application/schema.json +22 -0
  27. package/dist/generators/functionApplication/generator.d.ts +21 -0
  28. package/dist/generators/functionApplication/generator.d.ts.map +1 -0
  29. package/dist/generators/functionApplication/generator.js +43 -0
  30. package/dist/generators/functionApplication/generator.js.map +1 -0
  31. package/dist/generators/functionApplication/schema.json +22 -0
  32. package/dist/generators/internalLibrary/generator.d.ts +20 -0
  33. package/dist/generators/internalLibrary/generator.d.ts.map +1 -0
  34. package/dist/generators/internalLibrary/generator.js +39 -0
  35. package/dist/generators/internalLibrary/generator.js.map +1 -0
  36. package/dist/generators/internalLibrary/schema.json +22 -0
  37. package/dist/generators/library/generator.d.ts +23 -0
  38. package/dist/generators/library/generator.d.ts.map +1 -0
  39. package/dist/generators/library/generator.js +33 -0
  40. package/dist/generators/library/generator.js.map +1 -0
  41. package/dist/generators/library/schema.json +22 -0
  42. package/dist/index.d.ts +2 -0
  43. package/dist/index.d.ts.map +1 -0
  44. package/dist/index.js +3 -0
  45. package/dist/index.js.map +1 -0
  46. package/dist/internal/azureFunctionApp.d.ts +53 -0
  47. package/dist/internal/azureFunctionApp.d.ts.map +1 -0
  48. package/dist/internal/azureFunctionApp.js +89 -0
  49. package/dist/internal/azureFunctionApp.js.map +1 -0
  50. package/dist/internal/executorContext.d.ts +17 -0
  51. package/dist/internal/executorContext.d.ts.map +1 -0
  52. package/dist/internal/executorContext.js +26 -0
  53. package/dist/internal/executorContext.js.map +1 -0
  54. package/dist/internal/generateProject.d.ts +43 -0
  55. package/dist/internal/generateProject.d.ts.map +1 -0
  56. package/dist/internal/generateProject.js +58 -0
  57. package/dist/internal/generateProject.js.map +1 -0
  58. package/dist/internal/pythonProject.d.ts +57 -0
  59. package/dist/internal/pythonProject.d.ts.map +1 -0
  60. package/dist/internal/pythonProject.js +94 -0
  61. package/dist/internal/pythonProject.js.map +1 -0
  62. package/dist/internal/vendor.d.ts +42 -0
  63. package/dist/internal/vendor.d.ts.map +1 -0
  64. package/dist/internal/vendor.js +64 -0
  65. package/dist/internal/vendor.js.map +1 -0
  66. package/dist/release/versionActions.d.ts +107 -0
  67. package/dist/release/versionActions.d.ts.map +1 -0
  68. package/dist/release/versionActions.js +136 -0
  69. package/dist/release/versionActions.js.map +1 -0
  70. package/executors.json +25 -0
  71. package/generators.json +25 -0
  72. package/package.json +63 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pythonProject.d.ts","sourceRoot":"","sources":["../../src/internal/pythonProject.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,mBAAmB,CAAE,IAAI,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,MAAM,CAkBlF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAE,eAAe,EAAE,MAAM,GAAG,MAAM,CAInE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAE,eAAe,EAAE,MAAM,GAAG,MAAM,CAOjE"}
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pythonModuleDirectory = pythonModuleDirectory;
4
+ exports.pythonPyprojectToml = pythonPyprojectToml;
5
+ exports.pythonSampleModule = pythonSampleModule;
6
+ exports.pythonSampleTest = pythonSampleTest;
7
+ /**
8
+ * A Python project's module directory name, derived from its Nx project name.
9
+ *
10
+ * @remarks
11
+ * Python identifiers cannot contain hyphens, so `my-svc` becomes `my_svc`.
12
+ *
13
+ * @param name - The Nx project name.
14
+ * @returns The module directory's basename (e.g. `my_svc`).
15
+ * @throws Never - pure string mapping.
16
+ * @typeParam None - this function has no generic type parameters.
17
+ */
18
+ function pythonModuleDirectory(name) {
19
+ return name.replaceAll('-', '_');
20
+ }
21
+ /**
22
+ * The `pyproject.toml` written for a buildable Python project (app or lib).
23
+ *
24
+ * @remarks
25
+ * `hatchling` is the PEP 517 backend. The wheel target's `packages` list is
26
+ * explicit (not hatchling's own auto-detection) because the `build` executor
27
+ * patches this exact list when vendoring an internal-lib's module into the
28
+ * wheel (see `parseVendorEntries`). `dependencies` starts empty — external
29
+ * and vendored dependencies alike are wired by hand after generation; no
30
+ * generator wires cross-project Python dependencies automatically.
31
+ *
32
+ * @param name - The project name.
33
+ * @param moduleDirectory - The project's module directory basename.
34
+ * @returns The `pyproject.toml` contents.
35
+ * @throws Never - pure string build.
36
+ * @typeParam None - this function has no generic type parameters.
37
+ */
38
+ function pythonPyprojectToml(name, moduleDirectory) {
39
+ return `[project]
40
+ name = "${name}"
41
+ version = "1.0.0"
42
+ description = ""
43
+ requires-python = ">=3.9"
44
+ dependencies = []
45
+
46
+ [build-system]
47
+ requires = ["hatchling"]
48
+ build-backend = "hatchling.build"
49
+
50
+ [tool.hatch.build.targets.wheel]
51
+ packages = ["${moduleDirectory}"]
52
+
53
+ [tool.pytest.ini_options]
54
+ testpaths = ["tests"]
55
+ `;
56
+ }
57
+ /**
58
+ * A sample pure function written into a generated Python project's module.
59
+ *
60
+ * @remarks
61
+ * Gives every generated project a genuinely testable unit out of the box —
62
+ * paired with {@link pythonSampleTest}.
63
+ *
64
+ * @param moduleDirectory - The project's module directory basename.
65
+ * @returns The `<module>/__init__.py` contents.
66
+ * @throws Never - pure string build.
67
+ * @typeParam None - this function has no generic type parameters.
68
+ */
69
+ function pythonSampleModule(moduleDirectory) {
70
+ return `def hello() -> str:
71
+ return "hello from ${moduleDirectory}"
72
+ `;
73
+ }
74
+ /**
75
+ * The sample pytest proving a generated Python project's `test` target runs.
76
+ *
77
+ * @remarks
78
+ * Imports {@link pythonSampleModule}'s function, so a fresh project's `test`
79
+ * target is green out of the box, no wiring needed.
80
+ *
81
+ * @param moduleDirectory - The project's module directory basename.
82
+ * @returns The `tests/test_<module>.py` contents.
83
+ * @throws Never - pure string build.
84
+ * @typeParam None - this function has no generic type parameters.
85
+ */
86
+ function pythonSampleTest(moduleDirectory) {
87
+ return `from ${moduleDirectory} import hello
88
+
89
+
90
+ def test_hello() -> None:
91
+ assert hello() == "hello from ${moduleDirectory}"
92
+ `;
93
+ }
94
+ //# sourceMappingURL=pythonProject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pythonProject.js","sourceRoot":"","sources":["../../src/internal/pythonProject.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;GAUG;AACH,+BAAuC,IAAY;IACjD,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;AAClC,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,6BAAqC,IAAY,EAAE,eAAuB;IACxE,OAAO;UACC,IAAI;;;;;;;;;;;eAWC,eAAe;;;;CAI7B,CAAA;AACD,CAAC;AAED;;;;;;;;;;;GAWG;AACH,4BAAoC,eAAuB;IACzD,OAAO;yBACgB,eAAe;CACvC,CAAA;AACD,CAAC;AAED;;;;;;;;;;;GAWG;AACH,0BAAkC,eAAuB;IACvD,OAAO,QAAQ,eAAe;;;;oCAII,eAAe;CAClD,CAAA;AACD,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Extracts the vendored internal-lib project names from a `pyproject.toml`'s
3
+ * `[tool.mnci-python-pip] vendor = [...]` table.
4
+ *
5
+ * @remarks
6
+ * Plain pip has no bundled-local-dependency feature (the pip-world
7
+ * equivalent of `@nxlv/python`'s `bundleLocalDependencies`), so a project
8
+ * that imports a workspace-internal Python library needs this hand-added
9
+ * entry — the pip-world counterpart of hand-wiring a `dependencies = [...]`
10
+ * entry. This package wires no cross-project Python dependency
11
+ * automatically, for vendoring or otherwise.
12
+ *
13
+ * Parsed with a regex, not a TOML library: this package authors the exact
14
+ * shape of the table it looks for (`generateBuildableProject` never writes
15
+ * this table itself — it is always hand-added after generation), so a
16
+ * regex is sufficient and avoids a TOML dependency for one line.
17
+ *
18
+ * @param pyprojectToml - The `pyproject.toml` file contents.
19
+ * @returns The vendored project names (e.g. `["pycore"]`), or `[]` when the
20
+ * project vendors nothing.
21
+ * @throws Never - a missing/malformed table simply yields an empty array.
22
+ * @typeParam None - this function has no generic type parameters.
23
+ */
24
+ export declare function parseVendorEntries(pyprojectToml: string): string[];
25
+ /**
26
+ * Appends module directory names to a `pyproject.toml`'s
27
+ * `[tool.hatch.build.targets.wheel] packages` list.
28
+ *
29
+ * @remarks
30
+ * `generateBuildableProject` always writes this list with just the project's
31
+ * own module; a staged build (see the `build` executor) patches it here to
32
+ * also include each vendored module, so hatchling packages them as real
33
+ * top-level packages in the wheel.
34
+ *
35
+ * @param pyprojectToml - The staged `pyproject.toml` file contents.
36
+ * @param moduleDirectories - The vendored modules' directory names to add.
37
+ * @returns The patched `pyproject.toml` contents.
38
+ * @throws Never - when no `packages` list is found, the content is returned unchanged.
39
+ * @typeParam None - this function has no generic type parameters.
40
+ */
41
+ export declare function addPackagesToWheelTarget(pyprojectToml: string, moduleDirectories: string[]): string;
42
+ //# sourceMappingURL=vendor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vendor.d.ts","sourceRoot":"","sources":["../../src/internal/vendor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,kBAAkB,CAAE,aAAa,EAAE,MAAM,GAAG,MAAM,EAAE,CASnE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,wBAAwB,CAAE,aAAa,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,GAAG,MAAM,CASpG"}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseVendorEntries = parseVendorEntries;
4
+ exports.addPackagesToWheelTarget = addPackagesToWheelTarget;
5
+ /**
6
+ * Extracts the vendored internal-lib project names from a `pyproject.toml`'s
7
+ * `[tool.mnci-python-pip] vendor = [...]` table.
8
+ *
9
+ * @remarks
10
+ * Plain pip has no bundled-local-dependency feature (the pip-world
11
+ * equivalent of `@nxlv/python`'s `bundleLocalDependencies`), so a project
12
+ * that imports a workspace-internal Python library needs this hand-added
13
+ * entry — the pip-world counterpart of hand-wiring a `dependencies = [...]`
14
+ * entry. This package wires no cross-project Python dependency
15
+ * automatically, for vendoring or otherwise.
16
+ *
17
+ * Parsed with a regex, not a TOML library: this package authors the exact
18
+ * shape of the table it looks for (`generateBuildableProject` never writes
19
+ * this table itself — it is always hand-added after generation), so a
20
+ * regex is sufficient and avoids a TOML dependency for one line.
21
+ *
22
+ * @param pyprojectToml - The `pyproject.toml` file contents.
23
+ * @returns The vendored project names (e.g. `["pycore"]`), or `[]` when the
24
+ * project vendors nothing.
25
+ * @throws Never - a missing/malformed table simply yields an empty array.
26
+ * @typeParam None - this function has no generic type parameters.
27
+ */
28
+ function parseVendorEntries(pyprojectToml) {
29
+ const match = /^\s*vendor\s*=\s*\[([^\]]*)\]/m.exec(pyprojectToml);
30
+ if (!match) {
31
+ return [];
32
+ }
33
+ return match[1]
34
+ .split(',')
35
+ .map((entry) => entry.trim().replaceAll(/^["']|["']$/g, ''))
36
+ .filter(Boolean);
37
+ }
38
+ /**
39
+ * Appends module directory names to a `pyproject.toml`'s
40
+ * `[tool.hatch.build.targets.wheel] packages` list.
41
+ *
42
+ * @remarks
43
+ * `generateBuildableProject` always writes this list with just the project's
44
+ * own module; a staged build (see the `build` executor) patches it here to
45
+ * also include each vendored module, so hatchling packages them as real
46
+ * top-level packages in the wheel.
47
+ *
48
+ * @param pyprojectToml - The staged `pyproject.toml` file contents.
49
+ * @param moduleDirectories - The vendored modules' directory names to add.
50
+ * @returns The patched `pyproject.toml` contents.
51
+ * @throws Never - when no `packages` list is found, the content is returned unchanged.
52
+ * @typeParam None - this function has no generic type parameters.
53
+ */
54
+ function addPackagesToWheelTarget(pyprojectToml, moduleDirectories) {
55
+ return pyprojectToml.replace(/^(\s*packages\s*=\s*)\[([^\]]*)\]/m, (_match, prefix, existing) => {
56
+ const names = existing
57
+ .split(',')
58
+ .map((entry) => entry.trim().replaceAll(/^["']|["']$/g, ''))
59
+ .filter(Boolean);
60
+ const merged = [...new Set([...names, ...moduleDirectories])];
61
+ return `${prefix}[${merged.map((name) => `"${name}"`).join(', ')}]`;
62
+ });
63
+ }
64
+ //# sourceMappingURL=vendor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vendor.js","sourceRoot":"","sources":["../../src/internal/vendor.ts"],"names":[],"mappings":";;;;AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,4BAAoC,aAAqB;IACvD,MAAM,KAAK,GAAG,gCAAgC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;IAClE,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,EAAE,CAAA;IACX,CAAC;IACD,OAAO,KAAK,CAAC,CAAC,CAAC;SACZ,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;SAC3D,MAAM,CAAC,OAAO,CAAC,CAAA;AACpB,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,kCAA0C,aAAqB,EAAE,iBAA2B;IAC1F,OAAO,aAAa,CAAC,OAAO,CAAC,oCAAoC,EAAE,CAAC,MAAM,EAAE,MAAc,EAAE,QAAgB,EAAE,EAAE;QAC9G,MAAM,KAAK,GAAG,QAAQ;aACnB,KAAK,CAAC,GAAG,CAAC;aACV,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;aAC3D,MAAM,CAAC,OAAO,CAAC,CAAA;QAClB,MAAM,MAAM,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,KAAK,EAAE,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAA;QAC7D,OAAO,GAAG,MAAM,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAA;IACrE,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,107 @@
1
+ import type { ProjectGraph, Tree } from '@nx/devkit';
2
+ declare const VersionActions: typeof import("nx/release").VersionActions;
3
+ /**
4
+ * Hand-written Nx release `VersionActions` for pip-native Python packages
5
+ * (no uv, no Poetry) — reads/writes the `version = "..."` line under
6
+ * `pyproject.toml`'s `[project]` table.
7
+ *
8
+ * @remarks
9
+ * Registered per-project via `library` generator's
10
+ * `release.version.versionActions: '@mnci/nx-python-pip/release/version-actions'`
11
+ * (see `generateProject.ts`), which wins over whatever default the
12
+ * consuming workspace's `nx.json` configures. Verified empirically against a
13
+ * real `nx release version --dry-run` (both the disk-fallback and
14
+ * git-tag-based resolution paths).
15
+ *
16
+ * The `version = "..."` line is read/written with a regex, not a TOML
17
+ * library: this package authors `pyproject.toml`'s exact shape itself (via
18
+ * `pythonPyprojectToml`), so a regex on the one line that changes is safe
19
+ * and avoids a TOML dependency for it.
20
+ *
21
+ * @typeParam None - this class has no generic type parameters.
22
+ */
23
+ export default class PythonVersionActions extends VersionActions {
24
+ validManifestFilenames: string[];
25
+ /**
26
+ * Reads the current version from `pyproject.toml`'s `[project]` table.
27
+ *
28
+ * @param tree - The Nx virtual file system.
29
+ * @returns The current version and the manifest path, or `null` when the
30
+ * manifest does not exist.
31
+ * @throws Error when the manifest exists but has no `version = "..."` line.
32
+ * @typeParam None - this method has no generic type parameters.
33
+ */
34
+ readCurrentVersionFromSourceManifest(tree: Tree): Promise<{
35
+ currentVersion: string;
36
+ manifestPath: string;
37
+ } | null>;
38
+ /**
39
+ * Resolves the current published version via `pip index versions`.
40
+ *
41
+ * @remarks
42
+ * `pip index` is an experimental pip command (stable enough for this
43
+ * lookup); a package that has never been published, or a registry with no
44
+ * matching entry, is not an error here — it just means there is no
45
+ * registry-known current version yet, so `null` is returned instead of
46
+ * throwing (mirrors how a brand-new npm package behaves under the
47
+ * `registry` current-version resolver).
48
+ *
49
+ * @param _tree - Unused (the registry, not the workspace, is the source here).
50
+ * @param _currentVersionResolverMetadata - Unused (no registry-specific metadata needed).
51
+ * @returns The current published version (or `null`) and a log message.
52
+ * @throws Never - a lookup failure yields `null`, not a throw.
53
+ * @typeParam None - this method has no generic type parameters.
54
+ */
55
+ readCurrentVersionFromRegistry(_tree: Tree, _currentVersionResolverMetadata: Record<string, unknown> | undefined): Promise<{
56
+ currentVersion: string | null;
57
+ logText: string;
58
+ } | null>;
59
+ /**
60
+ * Resolves the current version of a dependency of this project.
61
+ *
62
+ * @remarks
63
+ * Internal-lib dependencies are vendored (copied into the wheel at build
64
+ * time by the `build` executor), not registry-referenced, so there is no
65
+ * separate version to track — the same branch `@nxlv/python`'s own
66
+ * reference implementation took for bundled dependencies.
67
+ *
68
+ * @param _tree - Unused.
69
+ * @param _projectGraph - Unused.
70
+ * @param _dependencyProjectName - Unused.
71
+ * @returns `null` for both fields — nothing to report.
72
+ * @throws Never - pure no-op.
73
+ * @typeParam None - this method has no generic type parameters.
74
+ */
75
+ readCurrentVersionOfDependency(_tree: Tree, _projectGraph: ProjectGraph, _dependencyProjectName: string): Promise<{
76
+ currentVersion: string | null;
77
+ dependencyCollection: string | null;
78
+ }>;
79
+ /**
80
+ * Writes the newly computed version into `pyproject.toml`.
81
+ *
82
+ * @param tree - The Nx virtual file system.
83
+ * @param newVersion - The new version to write.
84
+ * @returns A one-line log message describing the change.
85
+ * @throws Never - propagates only if the manifest genuinely cannot be read
86
+ * (would already have thrown in `readCurrentVersionFromSourceManifest`).
87
+ * @typeParam None - this method has no generic type parameters.
88
+ */
89
+ updateProjectVersion(tree: Tree, newVersion: string): Promise<string[]>;
90
+ /**
91
+ * Updates dependency versions in this project's manifest.
92
+ *
93
+ * @remarks
94
+ * Same reasoning as {@link readCurrentVersionOfDependency}: dependencies
95
+ * are vendored, not registry references, so there is nothing to update.
96
+ *
97
+ * @param _tree - Unused.
98
+ * @param _projectGraph - Unused.
99
+ * @param _dependenciesToUpdate - Unused.
100
+ * @returns An empty array — no log messages, nothing changed.
101
+ * @throws Never - pure no-op.
102
+ * @typeParam None - this method has no generic type parameters.
103
+ */
104
+ updateProjectDependencies(_tree: Tree, _projectGraph: ProjectGraph, _dependenciesToUpdate: Record<string, string>): Promise<string[]>;
105
+ }
106
+ export {};
107
+ //# sourceMappingURL=versionActions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"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AAM,EAAE,CAAC,CAEnB;CACF"}
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const node_child_process_1 = require("node:child_process");
4
+ const node_path_1 = require("node:path");
5
+ // eslint-disable-next-line @typescript-eslint/no-require-imports -- nx/release is CJS; no ESM entry to `import` from.
6
+ const { VersionActions } = require('nx/release');
7
+ const VERSION_LINE = /^version\s*=\s*"([^"]+)"/m;
8
+ /**
9
+ * Hand-written Nx release `VersionActions` for pip-native Python packages
10
+ * (no uv, no Poetry) — reads/writes the `version = "..."` line under
11
+ * `pyproject.toml`'s `[project]` table.
12
+ *
13
+ * @remarks
14
+ * Registered per-project via `library` generator's
15
+ * `release.version.versionActions: '@mnci/nx-python-pip/release/version-actions'`
16
+ * (see `generateProject.ts`), which wins over whatever default the
17
+ * consuming workspace's `nx.json` configures. Verified empirically against a
18
+ * real `nx release version --dry-run` (both the disk-fallback and
19
+ * git-tag-based resolution paths).
20
+ *
21
+ * The `version = "..."` line is read/written with a regex, not a TOML
22
+ * library: this package authors `pyproject.toml`'s exact shape itself (via
23
+ * `pythonPyprojectToml`), so a regex on the one line that changes is safe
24
+ * and avoids a TOML dependency for it.
25
+ *
26
+ * @typeParam None - this class has no generic type parameters.
27
+ */
28
+ class PythonVersionActions extends VersionActions {
29
+ constructor() {
30
+ super(...arguments);
31
+ this.validManifestFilenames = ['pyproject.toml'];
32
+ }
33
+ /**
34
+ * Reads the current version from `pyproject.toml`'s `[project]` table.
35
+ *
36
+ * @param tree - The Nx virtual file system.
37
+ * @returns The current version and the manifest path, or `null` when the
38
+ * manifest does not exist.
39
+ * @throws Error when the manifest exists but has no `version = "..."` line.
40
+ * @typeParam None - this method has no generic type parameters.
41
+ */
42
+ async readCurrentVersionFromSourceManifest(tree) {
43
+ const manifestPath = (0, node_path_1.join)(this.projectGraphNode.data.root, 'pyproject.toml');
44
+ const content = tree.read(manifestPath, 'utf8');
45
+ if (content === null) {
46
+ return null;
47
+ }
48
+ const match = VERSION_LINE.exec(content);
49
+ if (!match) {
50
+ throw new Error(`Could not find a "version = ..." line under [project] in ${manifestPath}`);
51
+ }
52
+ return { currentVersion: match[1], manifestPath };
53
+ }
54
+ /**
55
+ * Resolves the current published version via `pip index versions`.
56
+ *
57
+ * @remarks
58
+ * `pip index` is an experimental pip command (stable enough for this
59
+ * lookup); a package that has never been published, or a registry with no
60
+ * matching entry, is not an error here — it just means there is no
61
+ * registry-known current version yet, so `null` is returned instead of
62
+ * throwing (mirrors how a brand-new npm package behaves under the
63
+ * `registry` current-version resolver).
64
+ *
65
+ * @param _tree - Unused (the registry, not the workspace, is the source here).
66
+ * @param _currentVersionResolverMetadata - Unused (no registry-specific metadata needed).
67
+ * @returns The current published version (or `null`) and a log message.
68
+ * @throws Never - a lookup failure yields `null`, not a throw.
69
+ * @typeParam None - this method has no generic type parameters.
70
+ */
71
+ async readCurrentVersionFromRegistry(_tree, _currentVersionResolverMetadata) {
72
+ const name = this.projectGraphNode.name;
73
+ try {
74
+ const output = (0, node_child_process_1.execFileSync)('python3', ['-m', 'pip', 'index', 'versions', name], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] });
75
+ const match = /Available versions:\s*([^\s,]+)/.exec(output);
76
+ return { currentVersion: match ? match[1] : null, logText: 'from pip index versions' };
77
+ }
78
+ catch {
79
+ return { currentVersion: null, logText: 'package not found on registry' };
80
+ }
81
+ }
82
+ /**
83
+ * Resolves the current version of a dependency of this project.
84
+ *
85
+ * @remarks
86
+ * Internal-lib dependencies are vendored (copied into the wheel at build
87
+ * time by the `build` executor), not registry-referenced, so there is no
88
+ * separate version to track — the same branch `@nxlv/python`'s own
89
+ * reference implementation took for bundled dependencies.
90
+ *
91
+ * @param _tree - Unused.
92
+ * @param _projectGraph - Unused.
93
+ * @param _dependencyProjectName - Unused.
94
+ * @returns `null` for both fields — nothing to report.
95
+ * @throws Never - pure no-op.
96
+ * @typeParam None - this method has no generic type parameters.
97
+ */
98
+ async readCurrentVersionOfDependency(_tree, _projectGraph, _dependencyProjectName) {
99
+ return { currentVersion: null, dependencyCollection: null };
100
+ }
101
+ /**
102
+ * Writes the newly computed version into `pyproject.toml`.
103
+ *
104
+ * @param tree - The Nx virtual file system.
105
+ * @param newVersion - The new version to write.
106
+ * @returns A one-line log message describing the change.
107
+ * @throws Never - propagates only if the manifest genuinely cannot be read
108
+ * (would already have thrown in `readCurrentVersionFromSourceManifest`).
109
+ * @typeParam None - this method has no generic type parameters.
110
+ */
111
+ async updateProjectVersion(tree, newVersion) {
112
+ const manifestPath = (0, node_path_1.join)(this.projectGraphNode.data.root, 'pyproject.toml');
113
+ const content = tree.read(manifestPath, 'utf8') ?? '';
114
+ tree.write(manifestPath, content.replace(VERSION_LINE, () => `version = "${newVersion}"`));
115
+ return [`Updated ${manifestPath} to version ${newVersion}`];
116
+ }
117
+ /**
118
+ * Updates dependency versions in this project's manifest.
119
+ *
120
+ * @remarks
121
+ * Same reasoning as {@link readCurrentVersionOfDependency}: dependencies
122
+ * are vendored, not registry references, so there is nothing to update.
123
+ *
124
+ * @param _tree - Unused.
125
+ * @param _projectGraph - Unused.
126
+ * @param _dependenciesToUpdate - Unused.
127
+ * @returns An empty array — no log messages, nothing changed.
128
+ * @throws Never - pure no-op.
129
+ * @typeParam None - this method has no generic type parameters.
130
+ */
131
+ async updateProjectDependencies(_tree, _projectGraph, _dependenciesToUpdate) {
132
+ return [];
133
+ }
134
+ }
135
+ exports.default = PythonVersionActions;
136
+ //# sourceMappingURL=versionActions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"versionActions.js","sourceRoot":"","sources":["../../src/release/versionActions.ts"],"names":[],"mappings":";;AAAA,2DAAiD;AACjD,yCAAgC;AAEhC,sHAAsH;AACtH,MAAM,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,YAAY,CAAgC,CAAA;AAE/E,MAAM,YAAY,GAAG,2BAA2B,CAAA;AAEhD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,0BAA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AAC,CAAC,IAAI,EAAE,OAAO,EAAE,yBAAyB,EAAE,CAAA;QACxF,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,OAAO,EAAE,+BAA+B,EAAE,CAAA;QAC3E,CAAC;IACH,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACH,KAAK,CAAC,8BAA8B,CAClC,KAAW,EACX,aAA2B,EAC3B,sBAA8B;QAE9B,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAA;IAC7D,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,oBAAoB,CAAE,IAAU,EAAE,UAAkB;QACxD,MAAM,YAAY,GAAG,IAAA,gBAAI,EAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAA;QAC5E,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,IAAI,EAAE,CAAA;QACrD,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,OAAO,CAAC,OAAO,CAAC,YAAY,EAAE,GAAG,EAAE,CAAC,cAAc,UAAU,GAAG,CAAC,CAAC,CAAA;QAC1F,OAAO,CAAC,WAAW,YAAY,eAAe,UAAU,EAAE,CAAC,CAAA;IAC7D,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,yBAAyB,CAC7B,KAAW,EACX,aAA2B,EAC3B,qBAA6C;QAE7C,OAAO,EAAE,CAAA;IACX,CAAC;CACF"}
package/executors.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft-07/schema",
3
+ "executors": {
4
+ "build": {
5
+ "implementation": "./dist/executors/build/executor",
6
+ "schema": "./dist/executors/build/schema.json",
7
+ "description": "Build a Python wheel/sdist with python -m build, vendoring internal libs declared via [tool.mnci-python-pip] vendor."
8
+ },
9
+ "test": {
10
+ "implementation": "./dist/executors/test/executor",
11
+ "schema": "./dist/executors/test/schema.json",
12
+ "description": "Run pytest, optionally installing the project in editable mode first."
13
+ },
14
+ "lint": {
15
+ "implementation": "./dist/executors/lint/executor",
16
+ "schema": "./dist/executors/lint/schema.json",
17
+ "description": "Run ruff check ."
18
+ },
19
+ "publish": {
20
+ "implementation": "./dist/executors/publish/executor",
21
+ "schema": "./dist/executors/publish/schema.json",
22
+ "description": "Publish a wheel/sdist with twine upload; honours nx release publish --dry-run."
23
+ }
24
+ }
25
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft-07/schema",
3
+ "generators": {
4
+ "application": {
5
+ "factory": "./dist/generators/application/generator",
6
+ "schema": "./dist/generators/application/schema.json",
7
+ "description": "Create a pip-native Python application (pyproject.toml + project.json with lint/test/build targets)."
8
+ },
9
+ "library": {
10
+ "factory": "./dist/generators/library/generator",
11
+ "schema": "./dist/generators/library/schema.json",
12
+ "description": "Create a publishable pip-native Python library (adds a twine nx-release-publish target + a versionActions override)."
13
+ },
14
+ "internal-library": {
15
+ "factory": "./dist/generators/internalLibrary/generator",
16
+ "schema": "./dist/generators/internalLibrary/schema.json",
17
+ "description": "Create a private, never-published Python library (lint/test only)."
18
+ },
19
+ "function-application": {
20
+ "factory": "./dist/generators/functionApplication/generator",
21
+ "schema": "./dist/generators/functionApplication/schema.json",
22
+ "description": "Create a Python Azure Function app (v2 programming model), deployed as source, not a wheel."
23
+ }
24
+ }
25
+ }
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@mnci/nx-python-pip",
3
+ "version": "0.1.1",
4
+ "description": "An Nx plugin for pip-native Python projects (Ruff + pytest + the standard PyPA build/twine tools) — no uv, no Poetry, no lock file.",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "generators": "./generators.json",
9
+ "executors": "./executors.json",
10
+ "main": "./dist/index.js",
11
+ "types": "./dist/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "default": "./dist/index.js"
16
+ },
17
+ "./release/version-actions": {
18
+ "types": "./dist/release/versionActions.d.ts",
19
+ "default": "./dist/release/versionActions.js"
20
+ },
21
+ "./package.json": "./package.json",
22
+ "./generators.json": "./generators.json",
23
+ "./executors.json": "./executors.json"
24
+ },
25
+ "files": [
26
+ "dist",
27
+ "generators.json",
28
+ "executors.json"
29
+ ],
30
+ "scripts": {
31
+ "build": "tsc -p tsconfig.lib.json && node scripts/copySchemas.mjs",
32
+ "test": "jest",
33
+ "lint": "eslint ."
34
+ },
35
+ "keywords": [
36
+ "nx",
37
+ "nx-plugin",
38
+ "python",
39
+ "pip",
40
+ "azure-functions"
41
+ ],
42
+ "author": "Eduardo Russo",
43
+ "license": "MIT",
44
+ "repository": {
45
+ "type": "git",
46
+ "url": "git+https://github.com/russoedu/MoNecromanCi.git",
47
+ "directory": "packages/nx-python-pip"
48
+ },
49
+ "peerDependencies": {
50
+ "@nx/devkit": ">=21.0.0",
51
+ "nx": ">=21.0.0"
52
+ },
53
+ "devDependencies": {
54
+ "@nx/devkit": "23.1.0",
55
+ "@types/jest": "^30.0.0",
56
+ "@types/node": "^26.0.1",
57
+ "eslint": "^10.6.0",
58
+ "jest": "^30.4.2",
59
+ "nx": "23.1.0",
60
+ "ts-jest": "^29.4.11",
61
+ "typescript": "^6.0.3"
62
+ }
63
+ }