@dbx-tools/projen 0.9.21 → 0.9.29

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 (111) hide show
  1. package/README.md +77 -207
  2. package/index.ts +10 -14
  3. package/package.json +4 -4
  4. package/src/barrels.ts +1 -74
  5. package/src/module-exports.ts +175 -1
  6. package/src/openapi.ts +5 -72
  7. package/src/packages.ts +45 -0
  8. package/src/project-js.ts +3 -6
  9. package/src/project-predicate.ts +1 -2
  10. package/src/project-py.ts +82 -103
  11. package/src/project.ts +2 -2
  12. package/src/python-node-bindings.ts +138 -0
  13. package/src/python-node-bundle.ts +92 -0
  14. package/src/release-catalog.ts +3 -5
  15. package/src/{release-dispatch.ts → release-context.ts} +0 -11
  16. package/src/release.ts +70 -152
  17. package/tasks/bump.ts +12 -21
  18. package/tasks/databricks-cli-assets.ts +129 -0
  19. package/tasks/local-publish.ts +23 -107
  20. package/tasks/publish-npm.ts +10 -1
  21. package/tasks/publish-python.ts +26 -11
  22. package/tasks/publish.ts +12 -48
  23. package/tasks/python-node-bindings-watch.ts +47 -0
  24. package/tasks/python-node-bindings.ts +1017 -0
  25. package/tasks/python-release.ts +74 -0
  26. package/tasks/release.ts +99 -0
  27. package/tasks/sync.ts +13 -18
  28. package/tasks/version-check.ts +1 -28
  29. package/._LICENSE +0 -0
  30. package/._README.md +0 -0
  31. package/._index.ts +0 -0
  32. package/._package.json +0 -0
  33. package/src/.__lazy-require.ts +0 -0
  34. package/src/.__release-platform.ts +0 -0
  35. package/src/.__rust-project.ts +0 -0
  36. package/src/.__rust-release-workflow.ts +0 -0
  37. package/src/.__task-command.ts +0 -0
  38. package/src/._barrels.ts +0 -0
  39. package/src/._bun-app.ts +0 -0
  40. package/src/._bun-workflow.ts +0 -0
  41. package/src/._clean.ts +0 -0
  42. package/src/._codegen.ts +0 -0
  43. package/src/._dbx-tools-config.ts +0 -0
  44. package/src/._engine-root.ts +0 -0
  45. package/src/._generated.ts +0 -0
  46. package/src/._mixin.ts +0 -0
  47. package/src/._module-exports.ts +0 -0
  48. package/src/._openapi.ts +0 -0
  49. package/src/._packages.ts +0 -0
  50. package/src/._pnpm-workspace.ts +0 -0
  51. package/src/._project-js.ts +0 -0
  52. package/src/._project-predicate.ts +0 -0
  53. package/src/._project-py.ts +0 -0
  54. package/src/._project-rs.ts +0 -0
  55. package/src/._project.ts +0 -0
  56. package/src/._projen-version.ts +0 -0
  57. package/src/._publish.ts +0 -0
  58. package/src/._release-catalog.ts +0 -0
  59. package/src/._release-dispatch.ts +0 -0
  60. package/src/._release-github.ts +0 -0
  61. package/src/._release.ts +0 -0
  62. package/src/._scaffold.ts +0 -0
  63. package/src/._tags.ts +0 -0
  64. package/src/._tsconfig.ts +0 -0
  65. package/src/._uniffi.ts +0 -0
  66. package/src/._vscode.ts +0 -0
  67. package/src/._watch.ts +0 -0
  68. package/src/._workspace-lock.ts +0 -0
  69. package/src/._workspace-version.ts +0 -0
  70. package/src/_release-platform.ts +0 -78
  71. package/src/_rust-project.ts +0 -429
  72. package/src/_rust-release-workflow.ts +0 -311
  73. package/src/project-rs.ts +0 -1054
  74. package/src/release-github.ts +0 -109
  75. package/src/uniffi.ts +0 -65
  76. package/tasks/._barrels.ts +0 -0
  77. package/tasks/._bump.ts +0 -0
  78. package/tasks/._clean.ts +0 -0
  79. package/tasks/._compile-workspace.ts +0 -0
  80. package/tasks/._local-publish.ts +0 -0
  81. package/tasks/._openapi.ts +0 -0
  82. package/tasks/._projenrc.ts +0 -0
  83. package/tasks/._publish-npm.ts +0 -0
  84. package/tasks/._publish-python.ts +0 -0
  85. package/tasks/._publish-uniffi-local.ts +0 -0
  86. package/tasks/._publish.ts +0 -0
  87. package/tasks/._python-registry.ts +0 -0
  88. package/tasks/._release-assets.ts +0 -0
  89. package/tasks/._release-candidate.ts +0 -0
  90. package/tasks/._release-manifest.ts +0 -0
  91. package/tasks/._release-pr.ts +0 -0
  92. package/tasks/._release-summary.ts +0 -0
  93. package/tasks/._release-version.ts +0 -0
  94. package/tasks/._rust.ts +0 -0
  95. package/tasks/._sync.ts +0 -0
  96. package/tasks/._uniffi-python.d.ts +0 -0
  97. package/tasks/._uniffi-python.js +0 -0
  98. package/tasks/._uniffi-release.mjs +0 -0
  99. package/tasks/._uniffi.ts +0 -0
  100. package/tasks/._version-check.ts +0 -0
  101. package/tasks/publish-uniffi-local.ts +0 -359
  102. package/tasks/release-assets.ts +0 -467
  103. package/tasks/release-candidate.ts +0 -416
  104. package/tasks/release-manifest.ts +0 -273
  105. package/tasks/release-pr.ts +0 -589
  106. package/tasks/release-summary.ts +0 -379
  107. package/tasks/rust.ts +0 -173
  108. package/tasks/uniffi-python.d.ts +0 -60
  109. package/tasks/uniffi-python.js +0 -178
  110. package/tasks/uniffi-release.mjs +0 -579
  111. package/tasks/uniffi.ts +0 -262
@@ -1,178 +0,0 @@
1
- import {
2
- chmodSync,
3
- cpSync,
4
- existsSync,
5
- mkdirSync,
6
- mkdtempSync,
7
- readFileSync,
8
- readdirSync,
9
- rmSync,
10
- writeFileSync,
11
- } from "node:fs";
12
- import { tmpdir } from "node:os";
13
- import { basename, join, resolve } from "node:path";
14
-
15
- const READONLY = 0o444;
16
- const WRITABLE = 0o644;
17
-
18
- const projectTable = (document) => {
19
- const project = document?.project;
20
- if (!project || typeof project !== "object" || Array.isArray(project)) {
21
- throw new Error("Missing Python project metadata");
22
- }
23
- return project;
24
- };
25
-
26
- const directSibling = (dependency, sibling) => {
27
- const prefix = `${sibling.name} @ git+`;
28
- if (!dependency.startsWith(prefix)) return false;
29
- const marker = "#subdirectory=";
30
- const markerIndex = dependency.indexOf(marker, prefix.length);
31
- if (markerIndex < 0) return false;
32
- const directory = dependency.slice(markerIndex + marker.length);
33
- return directory === sibling.directory || directory.endsWith(`/${sibling.directory}`);
34
- };
35
-
36
- const setWritable = (path) => {
37
- if (existsSync(path)) chmodSync(path, WRITABLE);
38
- };
39
-
40
- const setReadonly = (path) => {
41
- if (existsSync(path)) chmodSync(path, READONLY);
42
- };
43
-
44
- const generatedHeader = (crate) =>
45
- [
46
- "# GENERATED by UniFFI binding generation - DO NOT EDIT.",
47
- `# Regenerated from the ${crate} Rust exports.`,
48
- "# Hand edits are overwritten on the next watch; this file is read-only.",
49
- "",
50
- ].join("\n");
51
-
52
- export const pythonProjectInfo = (source, toml) => {
53
- const document = toml.parse(source);
54
- const project = projectTable(document);
55
- if (typeof project.name !== "string" || !project.name) {
56
- throw new Error("Missing Python project name");
57
- }
58
- if (typeof project.version !== "string" || !project.version) {
59
- throw new Error("Missing Python project version");
60
- }
61
- const config = document?.tool?.["dbx-tools"];
62
- return {
63
- name: project.name,
64
- version: project.version,
65
- private: Boolean(config && typeof config === "object" && config.private === true),
66
- uniffi: Boolean(config && typeof config === "object" && config.uniffi === true),
67
- };
68
- };
69
-
70
- export const preparePythonProjectForPublication = (
71
- source,
72
- { packages, rewriteDependencies = true, toml, version },
73
- ) => {
74
- const marker = source.startsWith("# ") ? source.slice(0, source.indexOf("\n")) : undefined;
75
- const document = toml.parse(source);
76
- const project = projectTable(document);
77
- if (project.version !== version) {
78
- throw new Error(
79
- `Python project version ${String(project.version)} does not match release ${version}`,
80
- );
81
- }
82
- if (rewriteDependencies) {
83
- const dependencies = project.dependencies;
84
- if (dependencies !== undefined && !Array.isArray(dependencies)) {
85
- throw new Error("Python project dependencies must be an array");
86
- }
87
- if (dependencies) {
88
- project.dependencies = dependencies.map((dependency) => {
89
- if (typeof dependency !== "string") {
90
- throw new Error("Python project dependencies must be strings");
91
- }
92
- const sibling = packages.find((candidate) => directSibling(dependency, candidate));
93
- return sibling ? `${sibling.name}==${version}` : dependency;
94
- });
95
- }
96
- }
97
- const body = toml.stringify(document).trimEnd();
98
- return `${marker ? `${marker}\n\n` : ""}${body}\n`;
99
- };
100
-
101
- export const pythonBindingGeneratorName = (crate, platform) =>
102
- `${crate}-uniffi-bindgen${platform === "win32" ? ".exe" : ""}`;
103
-
104
- export const pythonBindingGeneratorArgs = ({ crate, library, output }) => [
105
- "generate",
106
- "--language",
107
- "python",
108
- "--crate",
109
- crate.replaceAll("-", "_"),
110
- "--out-dir",
111
- output,
112
- library,
113
- ];
114
-
115
- export const installPythonBindings = ({
116
- crate,
117
- library,
118
- module,
119
- packageRoot,
120
- platform,
121
- generatedSource,
122
- readonly = false,
123
- run,
124
- targetDirectory,
125
- }) => {
126
- const packageName = module.split(".").at(-1);
127
- if (!packageName) throw new Error(`Invalid Python module ${module}`);
128
- const packageDirectory = resolve(packageRoot, "src", ...module.split("."));
129
- const generatedDirectory = generatedSource
130
- ? undefined
131
- : mkdtempSync(join(tmpdir(), `${packageName}-python-`));
132
- const generator = resolve(targetDirectory, pythonBindingGeneratorName(crate, platform));
133
-
134
- try {
135
- if (!generatedSource) {
136
- if (!existsSync(generator)) throw new Error(`Missing UniFFI generator ${generator}`);
137
- run(
138
- generator,
139
- pythonBindingGeneratorArgs({
140
- crate,
141
- library,
142
- output: generatedDirectory,
143
- }),
144
- );
145
- }
146
- const generated =
147
- generatedSource ?? join(generatedDirectory, `${crate.replaceAll("-", "_")}.py`);
148
- if (!existsSync(generated)) throw new Error(`Missing generated binding ${generated}`);
149
- mkdirSync(packageDirectory, { recursive: true });
150
-
151
- const bindings = join(packageDirectory, "bindings.py");
152
- setWritable(bindings);
153
- writeFileSync(bindings, `${generatedHeader(crate)}${readFileSync(generated, "utf8")}`);
154
-
155
- const init = join(packageDirectory, "__init__.py");
156
- setWritable(init);
157
- writeFileSync(init, `${generatedHeader(crate)}from .bindings import *\n`);
158
-
159
- for (const candidate of readdirSync(packageDirectory)) {
160
- if (/\.(?:dll|dylib|so)$/.test(candidate)) {
161
- rmSync(join(packageDirectory, candidate), { force: true });
162
- }
163
- }
164
- const nativeLibrary = join(packageDirectory, basename(library));
165
- setWritable(nativeLibrary);
166
- cpSync(library, nativeLibrary);
167
-
168
- if (readonly) {
169
- setReadonly(bindings);
170
- setReadonly(init);
171
- setReadonly(nativeLibrary);
172
- }
173
- rmSync(join(packageDirectory, "_generated"), { recursive: true, force: true });
174
- return { bindings, init, library: nativeLibrary };
175
- } finally {
176
- if (generatedDirectory) rmSync(generatedDirectory, { recursive: true, force: true });
177
- }
178
- };