@kungfu-tech/buildchain 2.0.16-alpha.0 → 2.0.16

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.
@@ -10,6 +10,9 @@ const SUPPORTED_VERSION_FILE_TYPES = new Set(["json", "toml", "regex"]);
10
10
  const SUPPORTED_VERSION_STRATEGIES = new Set(["semver", "anchored"]);
11
11
  const SUPPORTED_VERSION_NEXT = new Set(["auto", "manual"]);
12
12
  const SUPPORTED_PROJECT_TYPES = new Set(["package", "web-surface"]);
13
+ const SUPPORTED_PUBLISH_MODES = new Set(["publish-final-version", "promote-existing-version"]);
14
+ const SUPPORTED_PUBLISH_AUTH = new Set(["trusted-publishing", "npm-token"]);
15
+ const SUPPORTED_PACKAGE_SET_ORDER = new Set(["as-provided", "platforms-first-main-last"]);
13
16
  const WEB_SURFACE_CHANNELS = ["preview", "staging", "production"];
14
17
  const SUPPORTED_CHANNEL_VISIBILITY = new Set(["ephemeral", "protected", "public", "internal"]);
15
18
  const SUPPORTED_ACCESS_CONTROL = new Set(["none", "managed-network", "edge-basic-auth", "oidc", "app-auth"]);
@@ -104,6 +107,9 @@ export function normalizeBuildchainConfig(config) {
104
107
  if (normalized.lifecycle !== undefined) {
105
108
  normalized.lifecycle = normalizeLifecycleSection(normalized.lifecycle);
106
109
  }
110
+ if (normalized.publish !== undefined) {
111
+ normalized.publish = normalizePublishSection(normalized.publish);
112
+ }
107
113
  if (normalized.channels !== undefined) {
108
114
  normalized.channels = normalizeChannelsSection(normalized.channels, normalized.project);
109
115
  }
@@ -120,6 +126,42 @@ export function normalizeBuildchainConfig(config) {
120
126
  return normalized;
121
127
  }
122
128
 
129
+ function normalizePublishSection(publish) {
130
+ assertPlainObject(publish, "publish");
131
+ const mode = publish.mode === undefined
132
+ ? "publish-final-version"
133
+ : assertString(publish.mode, "publish.mode");
134
+ if (!SUPPORTED_PUBLISH_MODES.has(mode)) {
135
+ throw new Error("publish.mode must be one of publish-final-version or promote-existing-version");
136
+ }
137
+ const auth = publish.auth === undefined
138
+ ? "trusted-publishing"
139
+ : assertString(publish.auth, "publish.auth");
140
+ if (!SUPPORTED_PUBLISH_AUTH.has(auth)) {
141
+ throw new Error("publish.auth must be one of trusted-publishing or npm-token");
142
+ }
143
+ if (mode === "promote-existing-version" && auth !== "npm-token") {
144
+ throw new Error('publish.mode = "promote-existing-version" requires publish.auth = "npm-token"');
145
+ }
146
+ const packageSetOrder = publish.package_set_order === undefined
147
+ ? "as-provided"
148
+ : assertString(publish.package_set_order, "publish.package_set_order");
149
+ if (!SUPPORTED_PACKAGE_SET_ORDER.has(packageSetOrder)) {
150
+ throw new Error("publish.package_set_order must be one of as-provided or platforms-first-main-last");
151
+ }
152
+ return {
153
+ mode,
154
+ auth,
155
+ distTag: publish.dist_tag === undefined
156
+ ? undefined
157
+ : assertString(publish.dist_tag, "publish.dist_tag"),
158
+ packageSetOrder,
159
+ mainPackage: publish.main_package === undefined
160
+ ? ""
161
+ : assertString(publish.main_package, "publish.main_package"),
162
+ };
163
+ }
164
+
123
165
  function normalizeProjectSection(project) {
124
166
  assertPlainObject(project, "project");
125
167
  const type = assertString(project.type, "project.type");
@@ -473,6 +515,10 @@ export function getLifecycleStage(loadedConfig, name) {
473
515
  return loadedConfig?.config?.lifecycle?.[name];
474
516
  }
475
517
 
518
+ export function getPublishContract(loadedConfig) {
519
+ return loadedConfig?.config?.publish;
520
+ }
521
+
476
522
  export function runLifecycleStage({ cwd = process.cwd(), loadedConfig, name, stage, env: extraEnv }) {
477
523
  const lifecycle = loadedConfig?.config?.lifecycle || {};
478
524
  const selected = stage || getLifecycleStage(loadedConfig, name);
@@ -706,6 +752,7 @@ export function validateBuildchainConfig(
706
752
  pattern: file.pattern?.source,
707
753
  })),
708
754
  lifecycleStages,
755
+ publish: loadedConfig.config.publish,
709
756
  };
710
757
  }
711
758
 
@@ -1,6 +1,7 @@
1
1
  export {
2
2
  discoverConfiguredVersionStateFiles,
3
3
  getLifecycleStage,
4
+ getPublishContract,
4
5
  getVersionStrategy,
5
6
  loadBuildchainConfig,
6
7
  loadConfiguredAnchorManifest,
@@ -216,12 +216,17 @@ export function normalizePublishArtifact(artifact, label = "artifact") {
216
216
  if (!artifact || typeof artifact !== "object" || Array.isArray(artifact)) {
217
217
  throw new Error(`${label} must be an object`);
218
218
  }
219
+ const role = optionalString(artifact.role);
220
+ if (role && !["main", "platform"].includes(role)) {
221
+ throw new Error(`${label}.role must be one of main or platform`);
222
+ }
219
223
  return {
220
224
  group: optionalString(artifact.group),
221
225
  kind: assertNonEmptyString(artifact.kind, `${label}.kind`),
222
226
  name: assertNonEmptyString(artifact.name, `${label}.name`),
223
227
  ref: optionalString(artifact.ref),
224
228
  digest: assertNonEmptyString(artifact.digest, `${label}.digest`),
229
+ role,
225
230
  required: artifact.required === undefined ? true : Boolean(artifact.required),
226
231
  };
227
232
  }
@@ -5,8 +5,16 @@ const root = process.cwd();
5
5
  const sharedActionTsupConfig = fs.readFileSync(path.join(root, "scripts/tsup-action.config.mjs"), "utf8");
6
6
  const commonJsSourcePattern = /\b(require\s*\(|module\.exports|exports\.|require\.main|createRequire)\b/;
7
7
  const requiredPaths = [
8
+ "AGENTS.md",
9
+ "CONTRIBUTING.md",
10
+ "LICENSE",
11
+ "LICENSE-POLICY.md",
8
12
  "README.md",
13
+ "SECURITY.md",
14
+ ".github/ISSUE_TEMPLATE/config.yml",
15
+ ".github/pull_request_template.md",
9
16
  "bin/buildchain.mjs",
17
+ "docs/MAP.md",
10
18
  "docs/cli.md",
11
19
  "scripts/release-line-dry-run.mjs",
12
20
  "scripts/npm-publish-dry-run.mjs",
@@ -53,7 +61,7 @@ if (rootPackage.publishConfig?.access !== "public") {
53
61
  if (rootPackage.publishConfig?.registry !== "https://registry.npmjs.org/") {
54
62
  throw new Error("root package publishConfig.registry must be npmjs");
55
63
  }
56
- for (const expectedFile of ["bin/", "scripts/*.mjs", "packages/core/", "docs/cli.md"]) {
64
+ for (const expectedFile of ["bin/", "scripts/*.mjs", "packages/core/", "docs/MAP.md", "docs/cli.md"]) {
57
65
  if (!rootPackage.files?.includes(expectedFile)) {
58
66
  throw new Error(`root package files must include ${expectedFile}`);
59
67
  }
@@ -152,7 +152,7 @@ export function npmPublishTransaction({
152
152
  const pkg = readPackageJson(resolvedCwd);
153
153
  const expectedVersion = readEnv("BUILDCHAIN_VERSION");
154
154
  const exactTag = assertPackageVersion({ pkg, expectedVersion });
155
- const distTag = pkg.version.includes("-") ? "alpha" : "latest";
155
+ const distTag = readEnv("BUILDCHAIN_NPM_DIST_TAG", pkg.version.includes("-") ? "alpha" : "latest");
156
156
 
157
157
  const pack = parsePackResult(runNpm({
158
158
  cwd: resolvedCwd,