@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
package/tasks/uniffi.ts DELETED
@@ -1,262 +0,0 @@
1
- #!/usr/bin/env -S bun
2
- import {
3
- cpSync,
4
- existsSync,
5
- mkdirSync,
6
- mkdtempSync,
7
- readFileSync,
8
- readdirSync,
9
- renameSync,
10
- rmSync,
11
- writeFileSync,
12
- } from "node:fs";
13
- import { tmpdir } from "node:os";
14
- import { basename, dirname, join, resolve } from "node:path";
15
- import { fileURLToPath } from "node:url";
16
- import { parseArgs } from "node:util";
17
- import { installPythonBindings } from "./uniffi-python.js";
18
- import { captureTaskCommand, runLoggedTaskCommand } from "../src/_task-command.ts";
19
- import { makeReadonly, makeWritable, stampGenerated } from "../src/generated.ts";
20
- import type { RustWorkspaceMapping } from "../src/project-rs.ts";
21
- import {
22
- addExplicitInterfaceReexports,
23
- addTypeScriptExtensionsToBindingImports,
24
- makeDefaultedInterfaceParametersOptional,
25
- removeObsoleteInterfaceAliases,
26
- } from "../src/uniffi.ts";
27
-
28
- const { values } = parseArgs({
29
- options: {
30
- root: { type: "string" },
31
- crate: { type: "string" },
32
- node: { type: "string" },
33
- python: { type: "string" },
34
- "python-module": { type: "string" },
35
- "cargo-target": { type: "string" },
36
- "node-package-base": { type: "string" },
37
- ubrn: { type: "string" },
38
- "skip-build": { type: "boolean" },
39
- "skip-barrels": { type: "boolean" },
40
- },
41
- });
42
- if (!values.crate || (!values.node && !values.python)) {
43
- throw new Error("Expected --crate and at least one of --node or --python");
44
- }
45
-
46
- const root = values.root
47
- ? resolve(values.root)
48
- : resolve(dirname(fileURLToPath(import.meta.url)), "../..");
49
- const crate = values.crate;
50
- const libraryName = crate.replaceAll("-", "_");
51
- const workspace = JSON.parse(readFileSync(join(root, "package.json"), "utf8")).dbxToolsConfig
52
- ?.rust as RustWorkspaceMapping | undefined;
53
- const binding = workspace?.bindings.find((binding) => binding.crate === crate);
54
- const dependencies =
55
- workspace?.bindings.filter((candidate) => binding?.dependencies?.includes(candidate.crate)) ?? [];
56
- const extension =
57
- process.platform === "darwin" ? "dylib" : process.platform === "win32" ? "dll" : "so";
58
- const prefix = process.platform === "win32" ? "" : "lib";
59
- const normalizedOutput = (value: string): string =>
60
- value
61
- .replace(/[\p{Extended_Pictographic}\uFE0F]/gu, "")
62
- .replace(/[ \t]+$/gm, "")
63
- .trim();
64
- const run = (command: string, args: string[]) => {
65
- runLoggedTaskCommand(root, command, args, {
66
- onLine: (line) => {
67
- const normalized = normalizedOutput(line);
68
- if (normalized) process.stdout.write(`${normalized}\n`);
69
- },
70
- });
71
- };
72
-
73
- const cargoTargetRoot = (
74
- JSON.parse(
75
- captureTaskCommand(root, "cargo", ["metadata", "--format-version", "1", "--no-deps"], {
76
- check: true,
77
- stderr: "inherit",
78
- }),
79
- ) as { target_directory?: unknown }
80
- ).target_directory;
81
- if (typeof cargoTargetRoot !== "string" || !cargoTargetRoot) {
82
- throw new Error("cargo metadata returned no target_directory");
83
- }
84
- const targetDirectory = values["cargo-target"]
85
- ? join(cargoTargetRoot, values["cargo-target"], "release")
86
- : join(cargoTargetRoot, "release");
87
- const library = join(targetDirectory, `${prefix}${libraryName}.${extension}`);
88
-
89
- const replaceGenerated = (source: string, destination: string): void => {
90
- const deadline = Date.now() + 5_000;
91
- const signal = new Int32Array(new SharedArrayBuffer(4));
92
- while (!existsSync(source) && Date.now() < deadline) Atomics.wait(signal, 0, 0, 25);
93
- if (!existsSync(source)) throw new Error(`Missing generated binding: ${source}`);
94
- mkdirSync(dirname(destination), { recursive: true });
95
- makeWritable(destination);
96
- rmSync(destination, { force: true });
97
- try {
98
- renameSync(source, destination);
99
- } catch (error) {
100
- if (!(error instanceof Error) || !("code" in error) || error.code !== "EXDEV") throw error;
101
- cpSync(source, destination);
102
- rmSync(source, { force: true });
103
- }
104
- };
105
-
106
- if (!values["skip-build"]) {
107
- run("cargo", [
108
- "build",
109
- "--release",
110
- ...(existsSync(join(root, "Cargo.lock")) ? ["--locked"] : []),
111
- "--package",
112
- crate,
113
- "--features",
114
- "uniffi-bindgen",
115
- ...(values["cargo-target"] ? ["--target", values["cargo-target"]] : []),
116
- ]);
117
- }
118
- if (!existsSync(library)) throw new Error(`Missing compiled UniFFI library: ${library}`);
119
-
120
- if (values.node) {
121
- const nodeSource = resolve(root, values.node, "src");
122
- const nodeOutput = mkdtempSync(join(tmpdir(), `${libraryName}-node-`));
123
- run(values.ubrn ? resolve(values.ubrn) : join(root, "node_modules/.bin/ubrn"), [
124
- "generate",
125
- "napi",
126
- "bindings",
127
- "--library",
128
- "--ts-dir",
129
- nodeOutput,
130
- ...(values["node-package-base"]
131
- ? ["--lib-package-base", values["node-package-base"], "--lib-node-triple"]
132
- : ["--lib-colocated"]),
133
- library,
134
- ]);
135
- const generatedModules = readdirSync(nodeOutput).filter(
136
- (file) => file.endsWith(".ts") && file !== "index.ts",
137
- );
138
- for (const dependency of dependencies) {
139
- if (!dependency.nodePackage) throw new Error(`Missing Node binding for ${dependency.crate}`);
140
- const namespace = dependency.crate.replaceAll("-", "_");
141
- for (const file of readdirSync(nodeOutput).filter((file) => file.endsWith(".ts"))) {
142
- const path = join(nodeOutput, file);
143
- const source = readFileSync(path, "utf8")
144
- .replace(
145
- new RegExp(`import (\\w+) from ["']\\./${namespace}["'];`, "g"),
146
- `import { uniffiModule as $1 } from "${dependency.nodePackage}";`,
147
- )
148
- .replaceAll(`'./${namespace}'`, `'${dependency.nodePackage}'`)
149
- .replaceAll(`"./${namespace}"`, `"${dependency.nodePackage}"`);
150
- writeFileSync(path, source);
151
- }
152
- for (const suffix of [".ts", "-ffi.ts"]) {
153
- const file = `${namespace}${suffix}`;
154
- rmSync(join(nodeOutput, file), { force: true });
155
- const index = generatedModules.indexOf(file);
156
- if (index >= 0) generatedModules.splice(index, 1);
157
- }
158
- }
159
- const ownModules = generatedModules.filter(
160
- (file) => file === `${libraryName}.ts` || file === `${libraryName}-ffi.ts`,
161
- );
162
- if (ownModules.length !== 2 || generatedModules.length !== 2) {
163
- throw new Error(`Unmapped UniFFI components in ${crate}: ${generatedModules.join(", ")}`);
164
- }
165
- writeFileSync(
166
- join(nodeOutput, "index.ts"),
167
- [
168
- `export * from './${libraryName}';`,
169
- `import uniffiModule from './${libraryName}';`,
170
- "uniffiModule.initialize();",
171
- "export { uniffiModule };",
172
- "export async function uniffiInitAsync() {}",
173
- "",
174
- ].join("\n"),
175
- );
176
- const nodeBindings = join(nodeSource, "bindings.ts");
177
- const generatedFiles = [join(nodeSource, "_bindings.ts"), join(nodeSource, "_bindings-ffi.ts")];
178
- const legacyExports = resolve(root, values.node, "exports.ts");
179
- if (
180
- existsSync(legacyExports) &&
181
- readFileSync(legacyExports, "utf8").trim() === 'export * from "./src/bindings.ts";'
182
- ) {
183
- makeWritable(legacyExports);
184
- rmSync(legacyExports, { force: true });
185
- }
186
- replaceGenerated(join(nodeOutput, "index.ts"), nodeBindings);
187
- replaceGenerated(join(nodeOutput, libraryName + ".ts"), generatedFiles[0]);
188
- replaceGenerated(join(nodeOutput, libraryName + "-ffi.ts"), generatedFiles[1]);
189
- writeFileSync(
190
- nodeBindings,
191
- readFileSync(nodeBindings, "utf8").replaceAll("./" + libraryName, "./_bindings"),
192
- );
193
- writeFileSync(
194
- generatedFiles[0],
195
- readFileSync(generatedFiles[0], "utf8").replaceAll(
196
- "./" + libraryName + "-ffi",
197
- "./_bindings-ffi",
198
- ),
199
- );
200
- for (const file of generatedFiles) {
201
- writeFileSync(
202
- file,
203
- removeObsoleteInterfaceAliases(
204
- makeDefaultedInterfaceParametersOptional(readFileSync(file, "utf8")),
205
- ),
206
- );
207
- }
208
- writeFileSync(
209
- nodeBindings,
210
- addExplicitInterfaceReexports(
211
- readFileSync(nodeBindings, "utf8"),
212
- generatedFiles.map((file) => ({
213
- specifier: `./${basename(file, ".ts")}`,
214
- source: readFileSync(file, "utf8"),
215
- })),
216
- ),
217
- );
218
- for (const file of [nodeBindings, ...generatedFiles]) {
219
- // Consumers type-check these files through workspace source exports, while
220
- // the generated runtime internals are validated by UniFFI's own build.
221
- const source = addTypeScriptExtensionsToBindingImports(readFileSync(file, "utf8")).replace(
222
- /[ \t]+$/gm,
223
- "",
224
- );
225
- writeFileSync(file, `/* eslint-disable */\n// @ts-nocheck\n${source}`);
226
- stampGenerated(file, {
227
- tool: "UniFFI binding generation",
228
- source: `the ${crate} Rust exports`,
229
- });
230
- }
231
- if (!values["node-package-base"]) {
232
- const nodeLibrary = join(nodeSource, basename(library));
233
- makeWritable(nodeLibrary);
234
- cpSync(library, nodeLibrary);
235
- makeReadonly(nodeLibrary);
236
- }
237
- rmSync(resolve(root, values.node, "src/generated"), { recursive: true, force: true });
238
- rmSync(nodeOutput, { recursive: true, force: true });
239
- if (!values["skip-barrels"]) {
240
- run(process.execPath, [
241
- resolve(dirname(fileURLToPath(import.meta.url)), "barrels.ts"),
242
- "--dir",
243
- resolve(root, values.node),
244
- ]);
245
- }
246
- }
247
-
248
- if (values.python) {
249
- if (!values["python-module"]) {
250
- throw new Error("Expected --python-module with --python");
251
- }
252
- installPythonBindings({
253
- crate,
254
- library,
255
- module: values["python-module"],
256
- packageRoot: resolve(root, values.python),
257
- platform: process.platform,
258
- readonly: true,
259
- run,
260
- targetDirectory,
261
- });
262
- }