@dbx-tools/projen 0.9.151 → 0.9.153

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.
@@ -0,0 +1,54 @@
1
+ /** Parse and print generated PyPI trusted-publisher setup instructions. */
2
+ import { z } from "zod";
3
+ import { taskCommand, taskOptions } from "./cli.ts";
4
+
5
+ export const PypiTrustedPublisherInstructionsOptionsSchema = z
6
+ .object({
7
+ secretFile: z
8
+ .string()
9
+ .trim()
10
+ .min(1)
11
+ .optional()
12
+ .describe("Credential file used only when browser authentication is required")
13
+ .meta({ env: [], helpDefault: false, short: false }),
14
+ })
15
+ .describe("Options for rendering PyPI trusted-publisher setup instructions");
16
+
17
+ /** Project-specific instruction sections wrapped around browser authentication guidance. */
18
+ export interface PypiTrustedPublisherInstructions {
19
+ readonly afterAuthentication: readonly string[];
20
+ readonly beforeAuthentication: readonly string[];
21
+ }
22
+
23
+ /** Parse task options and write the complete trusted-publisher instructions. */
24
+ export async function printPypiTrustedPublisherInstructions(
25
+ instructions: PypiTrustedPublisherInstructions,
26
+ argv: readonly string[] = process.argv.slice(2),
27
+ ): Promise<void> {
28
+ const { secretFile } = await taskOptions(
29
+ taskCommand(
30
+ import.meta.url,
31
+ "Print system-browser instructions for PyPI trusted publishers",
32
+ PypiTrustedPublisherInstructionsOptionsSchema,
33
+ ),
34
+ PypiTrustedPublisherInstructionsOptionsSchema,
35
+ argv,
36
+ );
37
+ const authentication = secretFile
38
+ ? [
39
+ `- If browser authentication is required, read credentials from ${secretFile} directly into the browser without printing, logging, or exposing secret values.`,
40
+ `- If ${secretFile} is absent, invalid, or insufficient for authentication, pause and ask the user to complete authentication.`,
41
+ ]
42
+ : [
43
+ "- If browser authentication is required, pause and ask the user to complete authentication.",
44
+ ];
45
+ process.stdout.write(
46
+ `${[
47
+ ...instructions.beforeAuthentication,
48
+ ...authentication,
49
+ ...instructions.afterAuthentication,
50
+ ]
51
+ .join("\n")
52
+ .trimEnd()}\n`,
53
+ );
54
+ }
@@ -13,7 +13,7 @@ import ts from "typescript";
13
13
  import { z } from "zod";
14
14
  import { runTaskMain, taskCommand, taskOptions } from "./cli.ts";
15
15
  import { TaskCheckOptionSchema, TaskForceOptionSchema, TaskRootOptionSchema } from "./options.ts";
16
- import { header, makeReadonly, makeWritable } from "../src/generated.ts";
16
+ import { header, headerLines, makeReadonly, makeWritable } from "../src/generated.ts";
17
17
  import { publicFunctionExports } from "../src/module-exports.ts";
18
18
  import { resolveRepoRoot } from "../src/packages.ts";
19
19
  import {
@@ -434,9 +434,11 @@ export async function main(args: string[] = process.argv.slice(2)): Promise<void
434
434
  section.includes("Callable["),
435
435
  );
436
436
  return [
437
- "# GENERATED by projen/tasks/python-node-bindings.ts - DO NOT EDIT.",
438
- `# Regenerated from ${source}.`,
439
- "# Hand edits are overwritten; this file is read-only.",
437
+ ...headerLines({
438
+ comment: "#",
439
+ tool: "projen/tasks/python-node-bindings.ts",
440
+ source,
441
+ }),
440
442
  "",
441
443
  "from __future__ import annotations",
442
444
  "",
@@ -1162,9 +1164,11 @@ function removeEmptyDirectories(directory: string): void {
1162
1164
 
1163
1165
  function pythonRuntimeLoader(source: string): string {
1164
1166
  return [
1165
- "# GENERATED by projen/tasks/python-node-bindings.ts - DO NOT EDIT.",
1166
- `# Regenerated from ${source}.`,
1167
- "# Hand edits are overwritten; this file is read-only.",
1167
+ ...headerLines({
1168
+ comment: "#",
1169
+ tool: "projen/tasks/python-node-bindings.ts",
1170
+ source,
1171
+ }),
1168
1172
  "",
1169
1173
  "from __future__ import annotations",
1170
1174
  "",
@@ -167,6 +167,8 @@ function selectedTests(
167
167
  ): string[] {
168
168
  const all = [
169
169
  ...graph.packages.flatMap((pkg) => testFiles(join(root, pkg.path, "test"))),
170
+ ...testFiles(join(root, "test")),
171
+ ...testFiles(join(root, "scripts")),
170
172
  ...testFiles(join(root, "docs/scripts")),
171
173
  ];
172
174
  if (mode === "unit") return all.filter((path) => !integrationTest(path));