@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.
- package/README.md +77 -207
- package/index.ts +10 -14
- package/package.json +4 -4
- package/src/barrels.ts +1 -74
- package/src/module-exports.ts +175 -1
- package/src/openapi.ts +5 -72
- package/src/packages.ts +45 -0
- package/src/project-js.ts +3 -6
- package/src/project-predicate.ts +1 -2
- package/src/project-py.ts +82 -103
- package/src/project.ts +2 -2
- package/src/python-node-bindings.ts +138 -0
- package/src/python-node-bundle.ts +92 -0
- package/src/release-catalog.ts +3 -5
- package/src/{release-dispatch.ts → release-context.ts} +0 -11
- package/src/release.ts +70 -152
- package/tasks/bump.ts +12 -21
- package/tasks/databricks-cli-assets.ts +129 -0
- package/tasks/local-publish.ts +23 -107
- package/tasks/publish-npm.ts +10 -1
- package/tasks/publish-python.ts +26 -11
- package/tasks/publish.ts +12 -48
- package/tasks/python-node-bindings-watch.ts +47 -0
- package/tasks/python-node-bindings.ts +1017 -0
- package/tasks/python-release.ts +74 -0
- package/tasks/release.ts +99 -0
- package/tasks/sync.ts +13 -18
- package/tasks/version-check.ts +1 -28
- package/._LICENSE +0 -0
- package/._README.md +0 -0
- package/._index.ts +0 -0
- package/._package.json +0 -0
- package/src/.__lazy-require.ts +0 -0
- package/src/.__release-platform.ts +0 -0
- package/src/.__rust-project.ts +0 -0
- package/src/.__rust-release-workflow.ts +0 -0
- package/src/.__task-command.ts +0 -0
- package/src/._barrels.ts +0 -0
- package/src/._bun-app.ts +0 -0
- package/src/._bun-workflow.ts +0 -0
- package/src/._clean.ts +0 -0
- package/src/._codegen.ts +0 -0
- package/src/._dbx-tools-config.ts +0 -0
- package/src/._engine-root.ts +0 -0
- package/src/._generated.ts +0 -0
- package/src/._mixin.ts +0 -0
- package/src/._module-exports.ts +0 -0
- package/src/._openapi.ts +0 -0
- package/src/._packages.ts +0 -0
- package/src/._pnpm-workspace.ts +0 -0
- package/src/._project-js.ts +0 -0
- package/src/._project-predicate.ts +0 -0
- package/src/._project-py.ts +0 -0
- package/src/._project-rs.ts +0 -0
- package/src/._project.ts +0 -0
- package/src/._projen-version.ts +0 -0
- package/src/._publish.ts +0 -0
- package/src/._release-catalog.ts +0 -0
- package/src/._release-dispatch.ts +0 -0
- package/src/._release-github.ts +0 -0
- package/src/._release.ts +0 -0
- package/src/._scaffold.ts +0 -0
- package/src/._tags.ts +0 -0
- package/src/._tsconfig.ts +0 -0
- package/src/._uniffi.ts +0 -0
- package/src/._vscode.ts +0 -0
- package/src/._watch.ts +0 -0
- package/src/._workspace-lock.ts +0 -0
- package/src/._workspace-version.ts +0 -0
- package/src/_release-platform.ts +0 -78
- package/src/_rust-project.ts +0 -429
- package/src/_rust-release-workflow.ts +0 -311
- package/src/project-rs.ts +0 -1054
- package/src/release-github.ts +0 -109
- package/src/uniffi.ts +0 -65
- package/tasks/._barrels.ts +0 -0
- package/tasks/._bump.ts +0 -0
- package/tasks/._clean.ts +0 -0
- package/tasks/._compile-workspace.ts +0 -0
- package/tasks/._local-publish.ts +0 -0
- package/tasks/._openapi.ts +0 -0
- package/tasks/._projenrc.ts +0 -0
- package/tasks/._publish-npm.ts +0 -0
- package/tasks/._publish-python.ts +0 -0
- package/tasks/._publish-uniffi-local.ts +0 -0
- package/tasks/._publish.ts +0 -0
- package/tasks/._python-registry.ts +0 -0
- package/tasks/._release-assets.ts +0 -0
- package/tasks/._release-candidate.ts +0 -0
- package/tasks/._release-manifest.ts +0 -0
- package/tasks/._release-pr.ts +0 -0
- package/tasks/._release-summary.ts +0 -0
- package/tasks/._release-version.ts +0 -0
- package/tasks/._rust.ts +0 -0
- package/tasks/._sync.ts +0 -0
- package/tasks/._uniffi-python.d.ts +0 -0
- package/tasks/._uniffi-python.js +0 -0
- package/tasks/._uniffi-release.mjs +0 -0
- package/tasks/._uniffi.ts +0 -0
- package/tasks/._version-check.ts +0 -0
- package/tasks/publish-uniffi-local.ts +0 -359
- package/tasks/release-assets.ts +0 -467
- package/tasks/release-candidate.ts +0 -416
- package/tasks/release-manifest.ts +0 -273
- package/tasks/release-pr.ts +0 -589
- package/tasks/release-summary.ts +0 -379
- package/tasks/rust.ts +0 -173
- package/tasks/uniffi-python.d.ts +0 -60
- package/tasks/uniffi-python.js +0 -178
- package/tasks/uniffi-release.mjs +0 -579
- package/tasks/uniffi.ts +0 -262
|
@@ -1,311 +0,0 @@
|
|
|
1
|
-
/** Rust release planning, candidate configuration, and Cargo promotion. */
|
|
2
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
-
import { createRequire } from "node:module";
|
|
4
|
-
import { dirname, join, resolve } from "node:path";
|
|
5
|
-
import { fileURLToPath } from "node:url";
|
|
6
|
-
import { TextFile, javascript } from "projen";
|
|
7
|
-
import { JobPermission, type Job } from "projen/lib/github/workflows-model";
|
|
8
|
-
import { UNIFFI_BINDGEN_FEATURE, type RustProject } from "./_rust-project.ts";
|
|
9
|
-
import type {
|
|
10
|
-
DBXToolsRustWorkspaceOptions,
|
|
11
|
-
RustBindingMapping,
|
|
12
|
-
RustReleaseOs,
|
|
13
|
-
UniFFIReleaseTarget,
|
|
14
|
-
} from "./project-rs.ts";
|
|
15
|
-
import { RELEASE_VERSION, releaseSourceSteps } from "./release-dispatch.ts";
|
|
16
|
-
import { releasePublishCondition } from "./release.ts";
|
|
17
|
-
|
|
18
|
-
const require = createRequire(import.meta.url);
|
|
19
|
-
type RustPackageDependencyResolver = (pkg: RustProject) => RustProject[];
|
|
20
|
-
|
|
21
|
-
function taskSource(name: string): string {
|
|
22
|
-
const sourceDirectory = dirname(fileURLToPath(import.meta.url));
|
|
23
|
-
const candidates = [
|
|
24
|
-
resolve(sourceDirectory, `../tasks/${name}`),
|
|
25
|
-
resolve(sourceDirectory, `../../tasks/${name}`),
|
|
26
|
-
];
|
|
27
|
-
const source = candidates.find(existsSync);
|
|
28
|
-
if (!source) throw new Error(`Could not locate tasks/${name}`);
|
|
29
|
-
return readFileSync(source, "utf8");
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function smolTomlSource(name: "dist/index.cjs" | "LICENSE"): string {
|
|
33
|
-
const entry = require.resolve("smol-toml");
|
|
34
|
-
return readFileSync(
|
|
35
|
-
resolve(dirname(entry), name === "LICENSE" ? "../LICENSE" : "index.cjs"),
|
|
36
|
-
"utf8",
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function orderRustBindings(bindings: readonly RustBindingMapping[]): RustBindingMapping[] {
|
|
41
|
-
const ordered: RustBindingMapping[] = [];
|
|
42
|
-
const visiting = new Set<string>();
|
|
43
|
-
const completed = new Set<string>();
|
|
44
|
-
const visit = (binding: RustBindingMapping): void => {
|
|
45
|
-
if (completed.has(binding.crate)) return;
|
|
46
|
-
if (visiting.has(binding.crate)) {
|
|
47
|
-
throw new Error(`Cyclic Rust binding dependency: ${binding.crate}`);
|
|
48
|
-
}
|
|
49
|
-
visiting.add(binding.crate);
|
|
50
|
-
for (const name of binding.dependencies ?? []) {
|
|
51
|
-
const dependency = bindings.find((candidate) => candidate.crate === name);
|
|
52
|
-
if (!dependency) throw new Error(`Missing Rust binding dependency: ${name}`);
|
|
53
|
-
visit(dependency);
|
|
54
|
-
}
|
|
55
|
-
visiting.delete(binding.crate);
|
|
56
|
-
completed.add(binding.crate);
|
|
57
|
-
ordered.push(binding);
|
|
58
|
-
};
|
|
59
|
-
for (const binding of bindings) visit(binding);
|
|
60
|
-
return ordered;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export interface RustReleaseBinding extends RustBindingMapping {
|
|
64
|
-
readonly node: string;
|
|
65
|
-
readonly python: string;
|
|
66
|
-
readonly nodePackage: string;
|
|
67
|
-
readonly pythonPackage: string;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export interface RustReleaseBinaryPlan {
|
|
71
|
-
readonly crate: string;
|
|
72
|
-
readonly binary: string;
|
|
73
|
-
readonly excludedOs: readonly RustReleaseOs[];
|
|
74
|
-
readonly requiredFeatures: readonly string[];
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export interface RustReleaseTargetPlan {
|
|
78
|
-
readonly runner: string;
|
|
79
|
-
readonly cargo: string;
|
|
80
|
-
readonly node: string;
|
|
81
|
-
readonly python: string;
|
|
82
|
-
readonly os: RustReleaseOs;
|
|
83
|
-
readonly cpu: string;
|
|
84
|
-
readonly libc: string;
|
|
85
|
-
readonly glibcVersion: string;
|
|
86
|
-
readonly packages: readonly string[];
|
|
87
|
-
readonly binaries: readonly string[];
|
|
88
|
-
readonly features: readonly string[];
|
|
89
|
-
readonly localFeatures: readonly string[];
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/** Generated release inputs shared by GitHub-hosted and local target builds. */
|
|
93
|
-
export interface RustReleaseConfiguration {
|
|
94
|
-
readonly releaseRustVersion: string;
|
|
95
|
-
readonly usesCargoLock: boolean;
|
|
96
|
-
readonly bindings: readonly RustReleaseBinding[];
|
|
97
|
-
readonly binaries: readonly RustReleaseBinaryPlan[];
|
|
98
|
-
readonly targets: readonly RustReleaseTargetPlan[];
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export interface RustReleasePlan {
|
|
102
|
-
readonly releaseRustVersion: string;
|
|
103
|
-
readonly releaseTask: string;
|
|
104
|
-
readonly bindings: readonly RustReleaseBinding[];
|
|
105
|
-
readonly nodeBindings: readonly RustReleaseBinding[];
|
|
106
|
-
readonly releaseBinaries: readonly RustReleaseBinaryPlan[];
|
|
107
|
-
readonly publicCrates: readonly string[];
|
|
108
|
-
readonly targets: readonly RustReleaseTargetPlan[];
|
|
109
|
-
readonly hasPythonBindings: boolean;
|
|
110
|
-
readonly usesCargoLock: boolean;
|
|
111
|
-
readonly usePreinstalledWindowsRust: boolean;
|
|
112
|
-
readonly hasTargetOutputs: boolean;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function releaseTargetPlan(
|
|
116
|
-
target: UniFFIReleaseTarget,
|
|
117
|
-
packages: readonly RustProject[],
|
|
118
|
-
binaries: readonly string[],
|
|
119
|
-
features: readonly string[],
|
|
120
|
-
localFeatures: readonly string[],
|
|
121
|
-
): RustReleaseTargetPlan {
|
|
122
|
-
const packageNames = packages.map((pkg) => pkg.crateName).sort();
|
|
123
|
-
const sortedBinaries = [...new Set(binaries)].sort();
|
|
124
|
-
const sortedFeatures = [...new Set(features)].sort();
|
|
125
|
-
return {
|
|
126
|
-
runner: target.runner,
|
|
127
|
-
cargo: target.cargo,
|
|
128
|
-
node: target.node,
|
|
129
|
-
python: target.python,
|
|
130
|
-
os: target.os,
|
|
131
|
-
cpu: target.cpu,
|
|
132
|
-
libc: target.libc ?? "",
|
|
133
|
-
glibcVersion: target.glibcVersion ?? "",
|
|
134
|
-
packages: packageNames,
|
|
135
|
-
binaries: sortedBinaries,
|
|
136
|
-
features: sortedFeatures,
|
|
137
|
-
localFeatures: [...new Set(localFeatures)].sort(),
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
export function planRustRelease(
|
|
142
|
-
project: javascript.NodeProject,
|
|
143
|
-
options: DBXToolsRustWorkspaceOptions,
|
|
144
|
-
targets: readonly UniFFIReleaseTarget[],
|
|
145
|
-
packages: readonly RustProject[],
|
|
146
|
-
bindingMappings: readonly RustBindingMapping[],
|
|
147
|
-
packageDependencies: RustPackageDependencyResolver,
|
|
148
|
-
): RustReleasePlan {
|
|
149
|
-
const releaseRustVersion = options.releaseRustVersion ?? "stable";
|
|
150
|
-
const bindings = bindingMappings.map((binding) => ({
|
|
151
|
-
...binding,
|
|
152
|
-
node: binding.node ?? "",
|
|
153
|
-
python: binding.python ?? "",
|
|
154
|
-
nodePackage: binding.nodePackage ?? "",
|
|
155
|
-
pythonPackage: binding.pythonPackage ?? "",
|
|
156
|
-
}));
|
|
157
|
-
const releaseBinaries = packages.flatMap((pkg) => [
|
|
158
|
-
...(pkg.packageOptions.release
|
|
159
|
-
? [
|
|
160
|
-
{
|
|
161
|
-
crate: pkg.crateName,
|
|
162
|
-
binary: pkg.packageOptions.binaryName ?? pkg.crateName,
|
|
163
|
-
excludedOs: pkg.packageOptions.releaseExcludeOs ?? [],
|
|
164
|
-
requiredFeatures: [],
|
|
165
|
-
},
|
|
166
|
-
]
|
|
167
|
-
: []),
|
|
168
|
-
...(pkg.packageOptions.binaries ?? [])
|
|
169
|
-
.filter((binary) => binary.release)
|
|
170
|
-
.map((binary) => ({
|
|
171
|
-
crate: pkg.crateName,
|
|
172
|
-
binary: binary.name,
|
|
173
|
-
excludedOs: binary.releaseExcludeOs ?? [],
|
|
174
|
-
requiredFeatures: binary.requiredFeatures ?? [],
|
|
175
|
-
})),
|
|
176
|
-
]);
|
|
177
|
-
const publicCrates = orderRustBindings(
|
|
178
|
-
packages
|
|
179
|
-
.filter((pkg) => !pkg.packageOptions.private)
|
|
180
|
-
.map((pkg) => ({
|
|
181
|
-
crate: pkg.crateName,
|
|
182
|
-
rust: pkg.outdir,
|
|
183
|
-
dependencies: packageDependencies(pkg).map((dependency) => dependency.crateName),
|
|
184
|
-
})),
|
|
185
|
-
).map((pkg) => pkg.crate);
|
|
186
|
-
const bindingPackages = packages.filter((pkg) =>
|
|
187
|
-
bindings.some((binding) => binding.crate === pkg.crateName),
|
|
188
|
-
);
|
|
189
|
-
const releaseTargets = targets.flatMap((target) => {
|
|
190
|
-
const selectedBinaries = releaseBinaries.filter(
|
|
191
|
-
(binary) => !binary.excludedOs.includes(target.os),
|
|
192
|
-
);
|
|
193
|
-
const binaryPackages = packages.filter((pkg) =>
|
|
194
|
-
selectedBinaries.some((binary) => binary.crate === pkg.crateName),
|
|
195
|
-
);
|
|
196
|
-
const selectedPackages = [...new Set([...bindingPackages, ...binaryPackages])];
|
|
197
|
-
if (!selectedPackages.length) return [];
|
|
198
|
-
const features = [
|
|
199
|
-
...bindingPackages.map((pkg) => `${pkg.crateName}/${UNIFFI_BINDGEN_FEATURE}`),
|
|
200
|
-
...selectedBinaries.flatMap((binary) =>
|
|
201
|
-
binary.requiredFeatures.map((feature) => `${binary.crate}/${feature}`),
|
|
202
|
-
),
|
|
203
|
-
];
|
|
204
|
-
const localFeatures = selectedPackages.flatMap((pkg) =>
|
|
205
|
-
(pkg.packageOptions.releaseLocalFeatures ?? []).map(
|
|
206
|
-
(feature) => `${pkg.crateName}/${feature}`,
|
|
207
|
-
),
|
|
208
|
-
);
|
|
209
|
-
return [
|
|
210
|
-
releaseTargetPlan(
|
|
211
|
-
target,
|
|
212
|
-
selectedPackages,
|
|
213
|
-
selectedBinaries.map((binary) => binary.binary),
|
|
214
|
-
features,
|
|
215
|
-
localFeatures,
|
|
216
|
-
),
|
|
217
|
-
];
|
|
218
|
-
});
|
|
219
|
-
const hasTargetOutputs = releaseTargets.length > 0;
|
|
220
|
-
if (hasTargetOutputs && targets.length === 0) {
|
|
221
|
-
throw new Error("Rust release requires at least one target");
|
|
222
|
-
}
|
|
223
|
-
return {
|
|
224
|
-
releaseRustVersion,
|
|
225
|
-
releaseTask: ".projen/uniffi-release.mjs",
|
|
226
|
-
bindings,
|
|
227
|
-
nodeBindings: bindings.filter((binding) => Boolean(binding.node && binding.nodePackage)),
|
|
228
|
-
releaseBinaries,
|
|
229
|
-
publicCrates,
|
|
230
|
-
targets: releaseTargets,
|
|
231
|
-
hasPythonBindings: bindings.some((binding) => binding.python),
|
|
232
|
-
usesCargoLock: existsSync(join(project.outdir, "Cargo.lock")),
|
|
233
|
-
usePreinstalledWindowsRust: releaseRustVersion === "stable",
|
|
234
|
-
hasTargetOutputs,
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
export function configureRustReleaseTask(
|
|
238
|
-
project: javascript.NodeProject,
|
|
239
|
-
plan: RustReleasePlan,
|
|
240
|
-
): void {
|
|
241
|
-
new TextFile(project, ".projen/rust-release.json", {
|
|
242
|
-
lines: JSON.stringify(
|
|
243
|
-
{
|
|
244
|
-
releaseRustVersion: plan.releaseRustVersion,
|
|
245
|
-
usesCargoLock: plan.usesCargoLock,
|
|
246
|
-
bindings: plan.bindings,
|
|
247
|
-
binaries: plan.releaseBinaries,
|
|
248
|
-
targets: plan.targets,
|
|
249
|
-
} satisfies RustReleaseConfiguration,
|
|
250
|
-
null,
|
|
251
|
-
2,
|
|
252
|
-
).split("\n"),
|
|
253
|
-
});
|
|
254
|
-
const bindingSupportFiles = [
|
|
255
|
-
plan.releaseTask,
|
|
256
|
-
".projen/uniffi-python.js",
|
|
257
|
-
".projen/smol-toml.cjs",
|
|
258
|
-
".projen/smol-toml.LICENSE",
|
|
259
|
-
] as const;
|
|
260
|
-
if (plan.bindings.length) {
|
|
261
|
-
new TextFile(project, plan.releaseTask, {
|
|
262
|
-
lines: taskSource("uniffi-release.mjs").trimEnd().split("\n"),
|
|
263
|
-
});
|
|
264
|
-
new TextFile(project, bindingSupportFiles[1], {
|
|
265
|
-
lines: taskSource("uniffi-python.js").trimEnd().split("\n"),
|
|
266
|
-
});
|
|
267
|
-
new TextFile(project, bindingSupportFiles[2], {
|
|
268
|
-
lines: smolTomlSource("dist/index.cjs").trimEnd().split("\n"),
|
|
269
|
-
});
|
|
270
|
-
new TextFile(project, bindingSupportFiles[3], {
|
|
271
|
-
lines: smolTomlSource("LICENSE").trimEnd().split("\n"),
|
|
272
|
-
});
|
|
273
|
-
} else {
|
|
274
|
-
for (const path of bindingSupportFiles) project.tryRemoveFile(path);
|
|
275
|
-
}
|
|
276
|
-
project.tryRemoveFile(".projen/rust-release.mjs");
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
export function rustCargoPublishJob(plan: RustReleasePlan): Job {
|
|
280
|
-
return {
|
|
281
|
-
if: releasePublishCondition("cargo", ["needs.verify-context.result == 'success'"]),
|
|
282
|
-
needs: ["verify-context"],
|
|
283
|
-
runsOn: ["ubuntu-latest"],
|
|
284
|
-
permissions: { contents: JobPermission.READ },
|
|
285
|
-
steps: [
|
|
286
|
-
...releaseSourceSteps(),
|
|
287
|
-
{
|
|
288
|
-
name: "Setup Rust",
|
|
289
|
-
uses: `dtolnay/rust-toolchain@${plan.releaseRustVersion}`,
|
|
290
|
-
},
|
|
291
|
-
{
|
|
292
|
-
name: "Publish public crates",
|
|
293
|
-
env: {
|
|
294
|
-
RELEASE_VERSION,
|
|
295
|
-
CARGO_REGISTRY_TOKEN: "${{ secrets.CARGO_REGISTRY_TOKEN }}",
|
|
296
|
-
},
|
|
297
|
-
run: plan.publicCrates
|
|
298
|
-
.map((crate) =>
|
|
299
|
-
[
|
|
300
|
-
`if cargo info "${crate}@$RELEASE_VERSION" >/dev/null 2>&1; then`,
|
|
301
|
-
` echo "skip published ${crate}@$RELEASE_VERSION"`,
|
|
302
|
-
"else",
|
|
303
|
-
` cargo publish --package "${crate}" --registry crates-io --locked`,
|
|
304
|
-
"fi",
|
|
305
|
-
].join("\n"),
|
|
306
|
-
)
|
|
307
|
-
.join("\n"),
|
|
308
|
-
},
|
|
309
|
-
],
|
|
310
|
-
};
|
|
311
|
-
}
|