@smoothbricks/nx-plugin 0.4.14 → 0.4.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.
- package/README.md +20 -3
- package/dist/deploy-policy.d.ts +26 -0
- package/dist/deploy-policy.d.ts.map +1 -0
- package/dist/deploy-policy.js +36 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +160 -37
- package/dist/managed-assets.d.ts +3 -0
- package/dist/managed-assets.d.ts.map +1 -0
- package/dist/managed-assets.js +3 -0
- package/dist/managed-files/ci-workflow.d.ts +215 -0
- package/dist/managed-files/ci-workflow.d.ts.map +1 -0
- package/dist/managed-files/ci-workflow.js +1082 -0
- package/dist/managed-files/context.d.ts +51 -0
- package/dist/managed-files/context.d.ts.map +1 -0
- package/dist/managed-files/context.js +206 -0
- package/dist/managed-files/files.d.ts +53 -0
- package/dist/managed-files/files.d.ts.map +1 -0
- package/dist/managed-files/files.js +248 -0
- package/dist/managed-files/generator.d.ts +16 -0
- package/dist/managed-files/generator.d.ts.map +1 -0
- package/dist/managed-files/generator.js +41 -0
- package/dist/managed-files/github-runs-on.d.ts +19 -0
- package/dist/managed-files/github-runs-on.d.ts.map +1 -0
- package/dist/managed-files/github-runs-on.js +48 -0
- package/dist/managed-files/managed-content.d.ts +45 -0
- package/dist/managed-files/managed-content.d.ts.map +1 -0
- package/dist/managed-files/managed-content.js +102 -0
- package/dist/managed-files/managed-format.d.ts +37 -0
- package/dist/managed-files/managed-format.d.ts.map +1 -0
- package/dist/managed-files/managed-format.js +94 -0
- package/dist/managed-files/paths.d.ts +8 -0
- package/dist/managed-files/paths.d.ts.map +1 -0
- package/dist/managed-files/paths.js +46 -0
- package/dist/managed-files/pr-preview-cleanup-workflow.d.ts +5 -0
- package/dist/managed-files/pr-preview-cleanup-workflow.d.ts.map +1 -0
- package/dist/managed-files/pr-preview-cleanup-workflow.js +38 -0
- package/dist/managed-files/private-npm-policy.d.ts +7 -0
- package/dist/managed-files/private-npm-policy.d.ts.map +1 -0
- package/dist/managed-files/private-npm-policy.js +51 -0
- package/dist/managed-files/publish-workflow.d.ts +150 -0
- package/dist/managed-files/publish-workflow.d.ts.map +1 -0
- package/dist/managed-files/publish-workflow.js +989 -0
- package/dist/managed-files/tree.d.ts +30 -0
- package/dist/managed-files/tree.d.ts.map +1 -0
- package/dist/managed-files/tree.js +91 -0
- package/dist/package-target-policy.d.ts +0 -1
- package/dist/package-target-policy.d.ts.map +1 -1
- package/dist/package-target-policy.js +50 -23
- package/dist/platform-targets.d.ts +5 -0
- package/dist/platform-targets.d.ts.map +1 -0
- package/dist/platform-targets.js +4 -0
- package/dist/typecheck-test-policy.d.ts +5 -9
- package/dist/typecheck-test-policy.d.ts.map +1 -1
- package/dist/typecheck-test-policy.js +69 -99
- package/dist/workspace-config-policy.d.ts +23 -3
- package/dist/workspace-config-policy.d.ts.map +1 -1
- package/dist/workspace-config-policy.js +35 -3
- package/dist/workspace-manifest.d.ts +291 -0
- package/dist/workspace-manifest.d.ts.map +1 -0
- package/dist/workspace-manifest.js +6 -0
- package/dist/workspace-package-policy.d.ts +13 -0
- package/dist/workspace-package-policy.d.ts.map +1 -0
- package/dist/workspace-package-policy.js +24 -0
- package/generators.json +5 -0
- package/managed/raw/envrc +20 -0
- package/managed/raw/git-format-staged.yml +82 -0
- package/managed/raw/gitattributes +8 -0
- package/managed/raw/tooling/devenv +83 -0
- package/managed/raw/tooling/direnv/devenv.smoo.nix +422 -0
- package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +251 -0
- package/managed/raw/tooling/direnv/merge-newer-pins.sh +48 -0
- package/managed/raw/tooling/direnv/repo-path +34 -0
- package/managed/raw/tooling/direnv/secret-references.ts +636 -0
- package/managed/raw/tooling/direnv/setup-environment.ts +585 -0
- package/managed/raw/tooling/direnv/toolchain-stamp.ts +88 -0
- package/managed/raw/tooling/git-hooks/commit-msg.sh +9 -0
- package/managed/raw/tooling/git-hooks/post-commit.sh +71 -0
- package/managed/raw/tooling/git-hooks/pre-commit.sh +18 -0
- package/managed/raw/tooling/git-hooks/pre-push.sh +48 -0
- package/managed/raw/tsconfig.lib.json +28 -0
- package/managed/templates/github/actions/cache-nix-devenv/action.yml +45 -0
- package/managed/templates/github/actions/cache-node-modules/action.yml +17 -0
- package/managed/templates/github/actions/cache-nx/action.yml +21 -0
- package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +19 -0
- package/managed/templates/github/actions/save-nix-devenv/action.yml +32 -0
- package/managed/templates/github/actions/setup-devenv/action.yml +241 -0
- package/managed/templates/github/workflows/managed-files.yml +127 -0
- package/package.json +89 -5
- package/src/bun-bootstrap.test.ts +0 -6
- package/src/deploy-policy.ts +40 -0
- package/src/index.test.ts +232 -9
- package/src/index.ts +187 -40
- package/src/managed-assets.ts +4 -0
- package/src/managed-files/ci-workflow.ts +1365 -0
- package/src/managed-files/context.ts +240 -0
- package/src/managed-files/files.ts +324 -0
- package/src/managed-files/generator.test.ts +151 -0
- package/src/managed-files/generator.ts +60 -0
- package/src/managed-files/github-runs-on.ts +51 -0
- package/src/managed-files/managed-content.test.ts +147 -0
- package/src/managed-files/managed-content.ts +121 -0
- package/src/managed-files/managed-format.ts +102 -0
- package/src/managed-files/paths.ts +44 -0
- package/src/managed-files/pr-preview-cleanup-workflow.ts +44 -0
- package/src/managed-files/private-npm-policy.ts +62 -0
- package/src/managed-files/publish-workflow.ts +1523 -0
- package/src/managed-files/schema.json +8 -0
- package/src/managed-files/tree-permissions.test.ts +109 -0
- package/src/managed-files/tree.test.ts +123 -0
- package/src/managed-files/tree.ts +118 -0
- package/src/package-target-policy.test.ts +4 -28
- package/src/package-target-policy.ts +55 -31
- package/src/platform-targets.ts +4 -0
- package/src/typecheck-test-policy.test.ts +28 -3
- package/src/typecheck-test-policy.ts +46 -121
- package/src/workspace-config-policy.test.ts +14 -2
- package/src/workspace-config-policy.ts +42 -3
- package/src/workspace-manifest.ts +327 -0
- package/src/workspace-package-policy.ts +32 -0
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ with `tsconfig.lib.json` receives transformer-aware `tsc-js` and native `typeche
|
|
|
10
10
|
`@smoothbricks/nx-plugin` also owns inferred targets Nx does not provide here:
|
|
11
11
|
|
|
12
12
|
- `typecheck-tests` and `typecheck-tests:watch` from `tsconfig.test.json`
|
|
13
|
-
- `test
|
|
13
|
+
- `test-watch` from explicit `test` commands for Bun and Vitest packages
|
|
14
14
|
- Cargo workspace targets from a neighboring workspace-root `Cargo.toml`
|
|
15
15
|
- aggregate `build` and `lint` targets
|
|
16
16
|
- an uncached `deploy` for a PRIVATE project with a wrangler manifest, running
|
|
@@ -171,7 +171,7 @@ Concrete targets come from concrete files:
|
|
|
171
171
|
- `typecheck-tests` is inferred from `tsconfig.test.json` and runs `tsc -p tsconfig.test.json --noEmit`. It first
|
|
172
172
|
rebuilds the current package's `tsc-js` output (or its non-TypeScript `build`) so self-imports resolve after `clean`.
|
|
173
173
|
- `typecheck-tests:watch` is inferred from `tsconfig.test.json` and runs the same typecheck in watch mode.
|
|
174
|
-
- `test
|
|
174
|
+
- `test-watch` is inferred when the package already defines an explicit Bun or Vitest `test` command. The plugin derives
|
|
175
175
|
the corresponding watch command and makes it depend on `typecheck-tests`.
|
|
176
176
|
- A workspace-root `Cargo.toml` provides `cargo-test`, `test`, `cargo-lint`, `mutation`, and `bench`.
|
|
177
177
|
`cargo-test-compile` warms one workspace `cargo test --no-run`. `cargo-test-archive` runs one
|
|
@@ -257,7 +257,7 @@ target such as `nx run pkg:cargo-wasm`.
|
|
|
257
257
|
There is no Nx `lint:fix` target; repository formatting is handled by the root `lint:fix` script.
|
|
258
258
|
|
|
259
259
|
`typecheck-tests` and `typecheck-tests:watch` are inferred only when `tsconfig.test.json` exists. Test typechecking must
|
|
260
|
-
not emit `dist-test`. `test
|
|
260
|
+
not emit `dist-test`. `test-watch` is continuous and depends on `typecheck-tests` before entering Bun or Vitest watch
|
|
261
261
|
mode. Smoo validation creates/requires this config for test runners that do not typecheck test files by default.
|
|
262
262
|
|
|
263
263
|
`tsconfig.test.json` is not a TypeScript build-mode project. It should reference library tsconfigs it needs to typecheck
|
|
@@ -339,3 +339,20 @@ The generator rewrites `package.json` so `nx.targets.test` uses:
|
|
|
339
339
|
- `timeoutMs: 600000`
|
|
340
340
|
- `killAfterMs: 10000`
|
|
341
341
|
- package script alias `nx run <project>:test --outputStyle=stream`
|
|
342
|
+
|
|
343
|
+
## Managed workspace files
|
|
344
|
+
|
|
345
|
+
`nx generate @smoothbricks/nx-plugin:managed-files` stages the same managed files as
|
|
346
|
+
`smoo monorepo update`, without installing packages or resolving secrets. Use Nx
|
|
347
|
+
`--dry-run` to inspect the changes. The workspace defaults register this generator
|
|
348
|
+
for `nx sync` and `nx sync:check`.
|
|
349
|
+
|
|
350
|
+
The plugin owns the packaged templates, pure rendering and content-preservation
|
|
351
|
+
functions. The generator reads workspace files through Nx `Tree` and uses Nx's
|
|
352
|
+
resolved project graph for inferred targets. The CLI only supplies the filesystem
|
|
353
|
+
and process boundary. There is no separate serialized change plan.
|
|
354
|
+
|
|
355
|
+
Files with a `# smoo-local` tail or `# smoo-local-begin` / `# smoo-local-end` blocks
|
|
356
|
+
retain those sections. Matching source symlinks are preserved; conflicting local
|
|
357
|
+
blocks and broken or external links are reported instead of overwritten. The
|
|
358
|
+
generator does not remove a repository-owned file when a capability is disabled.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type DeploymentStage = 'staging' | 'production' | `pr${number}`;
|
|
2
|
+
/** Deployed on staging only: infrastructure the pull-request stages share. */
|
|
3
|
+
export declare const STAGING_DEPLOY_TAG = "staging-deploy-target";
|
|
4
|
+
/** Excluded from every stage deploy; deployed outside the stage flow. */
|
|
5
|
+
export declare const PERMANENT_DEPLOY_TAG = "permanent-deploy-target";
|
|
6
|
+
/** Opts a project into the generated production-on-push deploy job. */
|
|
7
|
+
export declare const PRODUCTION_PUSH_DEPLOY_TAG = "production-push-deploy-target";
|
|
8
|
+
/**
|
|
9
|
+
* Whether the stage flow deploys a project, from its TAGS alone — the one rule
|
|
10
|
+
* CI selection and workflow generation both read, so a generated deploy job and
|
|
11
|
+
* the projects that job deploys cannot disagree.
|
|
12
|
+
*
|
|
13
|
+
* Having a `deploy` target is not that answer. A deploy target says a project
|
|
14
|
+
* CAN be deployed; only a tag says CI does it. A published library ships a
|
|
15
|
+
* wrangler manifest to document a Durable Object binding for its consumers, and
|
|
16
|
+
* that manifest is structurally identical to a deployable worker's — so the
|
|
17
|
+
* plugin infers `deploy` from one, and a repository that deploys nothing from CI
|
|
18
|
+
* would otherwise generate a deploy job, with cloud credentials, for it.
|
|
19
|
+
*
|
|
20
|
+
* The three tags compose as precedence, not as a set: `permanent` excludes a
|
|
21
|
+
* project from every stage, `staging` narrows it to one, `stage` generalizes it
|
|
22
|
+
* to all. `production-push` selects WITHIN this answer (see `--select-tag`) and
|
|
23
|
+
* never widens it.
|
|
24
|
+
*/
|
|
25
|
+
export declare function stageDeploysProject(tags: string[] | undefined, stage: DeploymentStage): boolean;
|
|
26
|
+
//# sourceMappingURL=deploy-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deploy-policy.d.ts","sourceRoot":"","sources":["../src/deploy-policy.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,YAAY,GAAG,KAAK,MAAM,EAAE,CAAC;AAKvE,8EAA8E;AAC9E,eAAO,MAAM,kBAAkB,0BAA0B,CAAC;AAE1D,yEAAyE;AACzE,eAAO,MAAM,oBAAoB,4BAA4B,CAAC;AAE9D,uEAAuE;AACvE,eAAO,MAAM,0BAA0B,kCAAkC,CAAC;AAE1E;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,KAAK,EAAE,eAAe,GAAG,OAAO,CAK/F"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// The Nx tags that drive stage deploys. CI selection (github-ci), workflow generation (monorepo)
|
|
2
|
+
// and the graph readers must agree on these, so they live here rather than with any one of them.
|
|
3
|
+
/** Deployed on every stage: one command that deploys whichever stage it is given. */
|
|
4
|
+
const STAGE_DEPLOY_TAG = 'stage-deploy-target';
|
|
5
|
+
/** Deployed on staging only: infrastructure the pull-request stages share. */
|
|
6
|
+
export const STAGING_DEPLOY_TAG = 'staging-deploy-target';
|
|
7
|
+
/** Excluded from every stage deploy; deployed outside the stage flow. */
|
|
8
|
+
export const PERMANENT_DEPLOY_TAG = 'permanent-deploy-target';
|
|
9
|
+
/** Opts a project into the generated production-on-push deploy job. */
|
|
10
|
+
export const PRODUCTION_PUSH_DEPLOY_TAG = 'production-push-deploy-target';
|
|
11
|
+
/**
|
|
12
|
+
* Whether the stage flow deploys a project, from its TAGS alone — the one rule
|
|
13
|
+
* CI selection and workflow generation both read, so a generated deploy job and
|
|
14
|
+
* the projects that job deploys cannot disagree.
|
|
15
|
+
*
|
|
16
|
+
* Having a `deploy` target is not that answer. A deploy target says a project
|
|
17
|
+
* CAN be deployed; only a tag says CI does it. A published library ships a
|
|
18
|
+
* wrangler manifest to document a Durable Object binding for its consumers, and
|
|
19
|
+
* that manifest is structurally identical to a deployable worker's — so the
|
|
20
|
+
* plugin infers `deploy` from one, and a repository that deploys nothing from CI
|
|
21
|
+
* would otherwise generate a deploy job, with cloud credentials, for it.
|
|
22
|
+
*
|
|
23
|
+
* The three tags compose as precedence, not as a set: `permanent` excludes a
|
|
24
|
+
* project from every stage, `staging` narrows it to one, `stage` generalizes it
|
|
25
|
+
* to all. `production-push` selects WITHIN this answer (see `--select-tag`) and
|
|
26
|
+
* never widens it.
|
|
27
|
+
*/
|
|
28
|
+
export function stageDeploysProject(tags, stage) {
|
|
29
|
+
if (tags === undefined)
|
|
30
|
+
return false;
|
|
31
|
+
if (tags.includes(PERMANENT_DEPLOY_TAG))
|
|
32
|
+
return false;
|
|
33
|
+
if (tags.includes(STAGING_DEPLOY_TAG))
|
|
34
|
+
return stage === 'staging';
|
|
35
|
+
return tags.includes(STAGE_DEPLOY_TAG);
|
|
36
|
+
}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAGL,KAAK,aAAa,EAGnB,MAAM,0BAA0B,CAAC;AAMlC,OAAO,EAKL,yBAAyB,EAa1B,MAAM,sBAAsB,CAAC;AAiB9B,OAAO,EAAE,yBAAyB,EAAE,CAAC;AAErC,gEAAgE;AAChE,eAAO,MAAM,aAAa,WAAW,CAAC;AACtC,uEAAuE;AACvE,eAAO,MAAM,mBAAmB,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAGL,KAAK,aAAa,EAGnB,MAAM,0BAA0B,CAAC;AAMlC,OAAO,EAKL,yBAAyB,EAa1B,MAAM,sBAAsB,CAAC;AAiB9B,OAAO,EAAE,yBAAyB,EAAE,CAAC;AAErC,gEAAgE;AAChE,eAAO,MAAM,aAAa,WAAW,CAAC;AACtC,uEAAuE;AACvE,eAAO,MAAM,mBAAmB,iBAAiB,CAAC;AAqQlD,KAAK,gBAAgB,GAAG,OAAO,GAAG,KAAK,CAAC;AACxC,KAAK,gBAAgB,GAAG,OAAO,GAAG,OAAO,CAAC;AAE1C,UAAU,YAAY;IACpB,YAAY,EAAE,gBAAgB,CAAC;IAC/B,YAAY,EAAE,gBAAgB,CAAC;CAChC;AAmID,UAAU,oBAAqB,SAAQ,YAAY;IACjD,UAAU,EAAE,MAAM,CAAC;CACpB;AA0CD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,oBAAoB,GAAG,MAAM,CAEhF;AAuWD,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,GAAG,aAAa,CAEvG;AAED,eAAO,MAAM,aAAa,EAAE,aAG3B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { existsSync } from 'node:fs';
|
|
1
|
+
import { existsSync, realpathSync } from 'node:fs';
|
|
2
2
|
import { readdir, readFile } from 'node:fs/promises';
|
|
3
3
|
import { createRequire } from 'node:module';
|
|
4
|
-
import { dirname, join, posix, relative } from 'node:path';
|
|
4
|
+
import { dirname, isAbsolute, join, posix, relative, resolve } from 'node:path';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
6
|
import { readJsonFile, } from 'nx/src/devkit-exports.js';
|
|
7
7
|
import { AggregateCreateNodesError } from 'nx/src/project-graph/error-types.js';
|
|
@@ -12,23 +12,26 @@ import { attributeCargoWorkspacePackages, CARGO_TEST_ARCHIVE_FILE, CARGO_TEST_AR
|
|
|
12
12
|
import { CARGO_CROSS_LINT_COMMAND, CARGO_CROSS_LINT_TARGET, CARGO_FETCH_COMMAND, CARGO_FETCH_TARGET, CARGO_FROZEN_PREFIX, CARGO_LINT_CLIPPY_COMMAND, cargoCrossTestArchiveFile, cargoCrossTestArchiveTargetName, cargoCrossTestTargetName, cargoFrozen, } from './cross-check-policy.js';
|
|
13
13
|
import { hashVersionlessCrateManifests } from './manifest-hash.js';
|
|
14
14
|
import { isNonSourceDirectory } from './source-directories.js';
|
|
15
|
-
import { PLATFORM_TARGET_GLOBS } from './workspace-config-policy.js';
|
|
15
|
+
import { isBuildOutputTargetName, isTestRunnerTargetName, PLATFORM_TARGET_GLOBS } from './workspace-config-policy.js';
|
|
16
16
|
export { CARGO_TEST_COMPILE_TARGET };
|
|
17
17
|
/** Makes a version live and proves it answers; never cached. */
|
|
18
18
|
export const DEPLOY_TARGET = 'deploy';
|
|
19
19
|
/** The purely file-derived half a deploy needs built first; cached. */
|
|
20
20
|
export const DEPLOY_BUILD_TARGET = 'deploy-build';
|
|
21
|
-
const BUILD_OUTPUT_TARGET_PATTERN = /-(?:js|web|html|css|android|native|napi|bun|wasm)$/;
|
|
22
21
|
/** The workspace-wide manifests a release rewrites: the version of every member, and the lockfile mirror of it. */
|
|
23
22
|
const RELEASE_REWRITTEN_WORKSPACE_INPUTS = ['{workspaceRoot}/package.json', '{workspaceRoot}/bun.lock'];
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
/** Installed-toolchain files a TypeScript task reads that no config can name. */
|
|
24
|
+
const TYPESCRIPT_PATCH_INPUTS = ['{workspaceRoot}/patches/**/*'];
|
|
25
|
+
/**
|
|
26
|
+
* The workspace's own base config, hashed for every TypeScript task whether or
|
|
27
|
+
* not this project's chain reaches it: it is where a workspace puts the options
|
|
28
|
+
* it means to apply to everything, and a project with no TypeScript config of
|
|
29
|
+
* its own has no chain to reach it with.
|
|
30
|
+
*/
|
|
31
|
+
const WORKSPACE_TSCONFIG_BASE_INPUT = '{workspaceRoot}/tsconfig.base.json';
|
|
29
32
|
/**
|
|
30
|
-
* The
|
|
31
|
-
*
|
|
33
|
+
* The two release-rewritten files hashed by field instead of by byte, for a
|
|
34
|
+
* check that only reads them.
|
|
32
35
|
*
|
|
33
36
|
* A `json` input is hashed by Nx's own hasher, so this costs no process. The
|
|
34
37
|
* lockfile's `workspaces` section is the mirror of each member's manifest —
|
|
@@ -36,11 +39,138 @@ const TYPESCRIPT_TOOLCHAIN_INPUTS = [
|
|
|
36
39
|
* hashed from the member's own `package.json`. Dropping that section keeps the
|
|
37
40
|
* resolution table, which is the reason the lockfile is an input at all.
|
|
38
41
|
*/
|
|
39
|
-
const
|
|
40
|
-
...TYPESCRIPT_TOOLCHAIN_INPUTS.filter((input) => !RELEASE_REWRITTEN_WORKSPACE_INPUTS.includes(input)),
|
|
42
|
+
const VERSIONLESS_TOOLCHAIN_MANIFEST_INPUTS = [
|
|
41
43
|
{ json: '{workspaceRoot}/package.json', excludeFields: ['version'] },
|
|
42
44
|
{ json: '{workspaceRoot}/bun.lock', excludeFields: ['workspaces'] },
|
|
43
45
|
];
|
|
46
|
+
/** A path segment Nx's workspace file map never carries, so a fileset naming it hashes nothing. */
|
|
47
|
+
const NODE_MODULES_SEGMENT = /(?:^|\/)node_modules(?:\/|$)/;
|
|
48
|
+
/**
|
|
49
|
+
* Every config file whose compiler options decide this project's TypeScript
|
|
50
|
+
* verdicts: the workspace base, plus every file reachable by `extends` from the
|
|
51
|
+
* configs its commands hand to `tsc`.
|
|
52
|
+
*
|
|
53
|
+
* Hashing only the named config is the bug this closes. A workspace whose
|
|
54
|
+
* project configs extend an INTERMEDIATE base — `packages/tsconfig.base.json`
|
|
55
|
+
* extending the root one — hashed the root and the named file and nothing in
|
|
56
|
+
* between, so flipping `noUnusedLocals` in the intermediate left every
|
|
57
|
+
* typecheck, test typecheck and emit serving its previous answer from cache:
|
|
58
|
+
* a pass for sources the compiler would now reject.
|
|
59
|
+
*
|
|
60
|
+
* Fail-closed. An `extends` that resolves to no file throws and names both
|
|
61
|
+
* files, because the only alternative is to drop an ancestor from the hash —
|
|
62
|
+
* which is the silence above. The ancestors this cannot name as a fileset are
|
|
63
|
+
* the two kinds Nx has no fileset for; see {@link configChainInput}.
|
|
64
|
+
*/
|
|
65
|
+
function typescriptConfigChainInputs(configPaths, workspaceRoot) {
|
|
66
|
+
const inputs = new Set([WORKSPACE_TSCONFIG_BASE_INPUT]);
|
|
67
|
+
const walked = new Set();
|
|
68
|
+
for (const configPath of configPaths) {
|
|
69
|
+
addTypescriptConfigAncestors(configPath, workspaceRoot, inputs, walked);
|
|
70
|
+
}
|
|
71
|
+
return [...inputs];
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* One config's ancestors; `walked` both dedupes shared bases and breaks an
|
|
75
|
+
* `extends` cycle.
|
|
76
|
+
*
|
|
77
|
+
* The walk stops at an ancestor Nx cannot hash, because everything reachable
|
|
78
|
+
* from an installed config is installed too: the lockfile pins that whole
|
|
79
|
+
* subtree, and parsing it could only invent failures for a dependency's own
|
|
80
|
+
* chain.
|
|
81
|
+
*/
|
|
82
|
+
function addTypescriptConfigAncestors(configPath, workspaceRoot, inputs, walked) {
|
|
83
|
+
if (walked.has(configPath))
|
|
84
|
+
return;
|
|
85
|
+
walked.add(configPath);
|
|
86
|
+
for (const specifier of typescriptConfigExtends(configPath)) {
|
|
87
|
+
const ancestor = resolveTypescriptConfigExtends(specifier, configPath);
|
|
88
|
+
const input = configChainInput(ancestor, configPath, workspaceRoot);
|
|
89
|
+
if (input === null)
|
|
90
|
+
continue;
|
|
91
|
+
inputs.add(input);
|
|
92
|
+
addTypescriptConfigAncestors(ancestor.path, workspaceRoot, inputs, walked);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/** What one config extends: a single specifier, or the ordered list TypeScript 5.0 added. */
|
|
96
|
+
function typescriptConfigExtends(configPath) {
|
|
97
|
+
const config = readJsonFile(configPath, { expectComments: true });
|
|
98
|
+
if (!isRecord(config))
|
|
99
|
+
throw new Error(`${configPath} is not a TypeScript configuration object`);
|
|
100
|
+
const extended = config.extends;
|
|
101
|
+
if (extended === undefined)
|
|
102
|
+
return [];
|
|
103
|
+
const specifiers = Array.isArray(extended) ? extended : [extended];
|
|
104
|
+
return specifiers.map((specifier) => {
|
|
105
|
+
if (typeof specifier !== 'string' || specifier.length === 0) {
|
|
106
|
+
throw new Error(`${configPath}: "extends" must name config files, not ${JSON.stringify(extended)}`);
|
|
107
|
+
}
|
|
108
|
+
return specifier;
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* One `extends` specifier as an absolute path, by TypeScript's own rules: a
|
|
113
|
+
* relative or rooted specifier is a path — with the `.json` extension it may
|
|
114
|
+
* omit — and anything else is a Node specifier resolved from the extending file.
|
|
115
|
+
*/
|
|
116
|
+
function resolveTypescriptConfigExtends(specifier, fromConfigPath) {
|
|
117
|
+
if (specifier.startsWith('./') || specifier.startsWith('../') || isAbsolute(specifier)) {
|
|
118
|
+
const direct = resolve(dirname(fromConfigPath), specifier);
|
|
119
|
+
const candidates = direct.endsWith('.json') ? [direct] : [direct, `${direct}.json`];
|
|
120
|
+
const found = candidates.find((candidate) => existsSync(candidate));
|
|
121
|
+
if (found !== undefined)
|
|
122
|
+
return { path: found, installed: false };
|
|
123
|
+
throw new Error(`${fromConfigPath}: "extends": "${specifier}" names no file (looked for ${candidates.join(', ')}). ` +
|
|
124
|
+
'Every config in the chain is hashed, so one that cannot be found cannot be left out of the hash either.');
|
|
125
|
+
}
|
|
126
|
+
// A package config may be named by file or bare; TypeScript accepts both.
|
|
127
|
+
const candidates = specifier.endsWith('.json') ? [specifier] : [specifier, `${specifier}/tsconfig.json`];
|
|
128
|
+
const nodeRequire = createRequire(fromConfigPath);
|
|
129
|
+
for (const candidate of candidates) {
|
|
130
|
+
try {
|
|
131
|
+
return { path: nodeRequire.resolve(candidate), installed: true };
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
// Not this spelling of the package config; try the next, then refuse.
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
throw new Error(`${fromConfigPath}: "extends": "${specifier}" resolves to no installed config (tried ${candidates.join(', ')}). ` +
|
|
138
|
+
'Every config in the chain is hashed, so one that cannot be found cannot be left out of the hash either.');
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* The fileset name for one ancestor, or `null` when Nx cannot hash that file.
|
|
142
|
+
*
|
|
143
|
+
* Nx hashes workspace files that are not in node_modules, so two ancestor
|
|
144
|
+
* kinds cannot be named — and they are not the same thing:
|
|
145
|
+
*
|
|
146
|
+
* - a dependency's config: `bun.lock` and the root manifest decide which
|
|
147
|
+
* bytes are installed, and both are already inputs. Where they sit is the
|
|
148
|
+
* installer's business — bun keeps them in a global store outside the
|
|
149
|
+
* workspace entirely — so this is settled by HOW the specifier resolved,
|
|
150
|
+
* not by where it landed. A workspace member reached through its package
|
|
151
|
+
* name is workspace source, and is hashed as such.
|
|
152
|
+
* - a path above the workspace root: nothing hashes it and nothing pins it,
|
|
153
|
+
* so an edit there really can serve a stale verdict. Said out loud,
|
|
154
|
+
* because the silent version of exactly that is the bug this walk closes.
|
|
155
|
+
*/
|
|
156
|
+
function configChainInput(ancestor, fromConfigPath, workspaceRoot) {
|
|
157
|
+
let relativePath = relative(workspaceRoot, ancestor.path).replaceAll('\\', '/');
|
|
158
|
+
if (relativePath.startsWith('../')) {
|
|
159
|
+
// Node resolves a package to its REAL path, and a workspace root can itself
|
|
160
|
+
// be reached through a symlink (macOS `/var` → `/private/var`): a workspace
|
|
161
|
+
// member then looks like a file above the root. Believe the real root
|
|
162
|
+
// before concluding anything is outside.
|
|
163
|
+
relativePath = relative(realpathSync(workspaceRoot), ancestor.path).replaceAll('\\', '/');
|
|
164
|
+
}
|
|
165
|
+
const outsideWorkspace = relativePath.length === 0 || relativePath.startsWith('../') || isAbsolute(relativePath);
|
|
166
|
+
if (!outsideWorkspace && !NODE_MODULES_SEGMENT.test(relativePath))
|
|
167
|
+
return `{workspaceRoot}/${relativePath}`;
|
|
168
|
+
if (!ancestor.installed) {
|
|
169
|
+
process.stderr.write(`@smoothbricks/nx-plugin: ${fromConfigPath} extends ${ancestor.path}, which is outside the workspace. ` +
|
|
170
|
+
'Nx hashes workspace files only, so a change to it will not invalidate this project\u2019s TypeScript tasks.\n');
|
|
171
|
+
}
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
44
174
|
/**
|
|
45
175
|
* A project's own manifest, hashed without the version a release rewrites.
|
|
46
176
|
*
|
|
@@ -148,32 +278,17 @@ function hostPlatformTargetNames(targetNames, hostPlatform) {
|
|
|
148
278
|
* its name ends in a family: `*-js`, `*-web`, `*-html`, `*-css`, `*-android`,
|
|
149
279
|
* `*-native`, `*-napi`, `*-bun`, `*-wasm`.
|
|
150
280
|
*
|
|
151
|
-
* Two spellings of the same collision. A per-crate cargo test runner is
|
|
152
|
-
* `cargo-test-<crate>`, so any crate whose name ends in a family put its RUNNER
|
|
153
|
-
* in the aggregate; the runners are one serialized chain, so a single such
|
|
154
|
-
* crate made `build` pull an entire cargo test suite. A bun suite named
|
|
155
|
-
* `test-bun` is the collision without the prefix — a runner reading as
|
|
156
|
-
* "tool=test, output=bun", swept into `build` by suffix alone. That one forced
|
|
157
|
-
* a consumer to hand-declare `build` purely to replace the inferred list.
|
|
158
|
-
*
|
|
159
281
|
* So the rule is the CLASS, not one namespace: a target that RUNS tests is
|
|
160
282
|
* never a build output, however it is spelled. Expanding the families here
|
|
161
|
-
* rather than delegating to Nx's matcher is what makes that expressible
|
|
283
|
+
* rather than delegating to Nx's matcher is what makes that expressible, and
|
|
284
|
+
* `package-target-policy` reads the same two predicates to decide whether a
|
|
285
|
+
* hand-declared aggregate is naming an edge this list already produces.
|
|
162
286
|
*/
|
|
163
287
|
function buildOutputTargetNames(targetNames) {
|
|
164
288
|
return [...new Set(targetNames)]
|
|
165
|
-
.filter((name) =>
|
|
289
|
+
.filter((name) => isBuildOutputTargetName(name) && !isTestRunnerTargetName(name))
|
|
166
290
|
.sort();
|
|
167
291
|
}
|
|
168
|
-
/**
|
|
169
|
-
* A target whose job is to RUN tests. `test`, anything under `test-`/`test:`,
|
|
170
|
-
* and the plugin's own `cargo-test-<crate>` namespace. Deliberately name-based:
|
|
171
|
-
* the aggregate is assembled from declared AND inferred target names, and a
|
|
172
|
-
* declaration carries no marker saying "this executes rather than emits".
|
|
173
|
-
*/
|
|
174
|
-
function isTestRunnerTargetName(name) {
|
|
175
|
-
return (name === 'test' || name.startsWith('test-') || name.startsWith('test:') || name.startsWith(`${CARGO_TEST_TARGET}-`));
|
|
176
|
-
}
|
|
177
292
|
//#region smoo!n/rust-output-target-inference
|
|
178
293
|
// Cargo workspace inference: a package.json sitting next to a Cargo.toml that
|
|
179
294
|
// declares [workspace] gets direct cargo-test/test targets, cargo-lint feeding
|
|
@@ -674,6 +789,8 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
674
789
|
const validationTargets = [];
|
|
675
790
|
const libTsconfigPath = join(absoluteProjectRoot, 'tsconfig.lib.json');
|
|
676
791
|
const hasLibTsconfig = existsSync(libTsconfigPath);
|
|
792
|
+
const testTsconfigPath = join(absoluteProjectRoot, 'tsconfig.test.json');
|
|
793
|
+
const hasTestTsconfig = existsSync(testTsconfigPath);
|
|
677
794
|
const cargoTomlPath = join(absoluteProjectRoot, 'Cargo.toml');
|
|
678
795
|
const isCargoWorkspace = existsSync(cargoTomlPath) && CARGO_WORKSPACE_PATTERN.test(await readFile(cargoTomlPath, 'utf-8'));
|
|
679
796
|
const cargoWorkspace = cargoWorkspaces.find((workspace) => workspace.projectRoot === projectRoot) ??
|
|
@@ -691,7 +808,14 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
691
808
|
const hasCrateManifests = isCargoProject || existsSync(cargoTomlPath);
|
|
692
809
|
const crateInputs = versionless !== null && hasCrateManifests ? await versionlessCrateInputs(projectRoot, workspaceRoot) : [];
|
|
693
810
|
const versionlessProjectInputs = versionless === null ? [] : [...VERSIONLESS_PACKAGE_INPUTS, ...crateInputs];
|
|
694
|
-
|
|
811
|
+
// The options a TypeScript task's answer really depends on, which is the
|
|
812
|
+
// whole `extends` chain of the configs its commands name and not just those
|
|
813
|
+
// two files. Resolved once per project: every target below shares it.
|
|
814
|
+
const typescriptConfigChain = typescriptConfigChainInputs([...(hasLibTsconfig ? [libTsconfigPath] : []), ...(hasTestTsconfig ? [testTsconfigPath] : [])], workspaceRoot);
|
|
815
|
+
const toolchainInputs = [...RELEASE_REWRITTEN_WORKSPACE_INPUTS, ...TYPESCRIPT_PATCH_INPUTS, ...typescriptConfigChain];
|
|
816
|
+
const checkInputs = versionless === null
|
|
817
|
+
? toolchainInputs
|
|
818
|
+
: [...TYPESCRIPT_PATCH_INPUTS, ...typescriptConfigChain, ...VERSIONLESS_TOOLCHAIN_MANIFEST_INPUTS];
|
|
695
819
|
const selfProduction = versionless === null ? 'production' : VERSIONLESS_PRODUCTION_INPUT;
|
|
696
820
|
const selfDefault = versionless === null ? 'default' : VERSIONLESS_DEFAULT_INPUT;
|
|
697
821
|
const dependencyProduction = versionless?.transitive === true
|
|
@@ -718,7 +842,7 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
718
842
|
targets['tsc-js'] = {
|
|
719
843
|
executor: '@smoothbricks/nx-plugin:typescript-emit',
|
|
720
844
|
cache: true,
|
|
721
|
-
inputs: ['production', '^production', ...
|
|
845
|
+
inputs: ['production', '^production', ...toolchainInputs, '{projectRoot}/tsconfig.lib.json'],
|
|
722
846
|
outputs: inferTypescriptOutputs(libTsconfigPath, packageJsonPath),
|
|
723
847
|
dependsOn: ['^*-js', ...(cargoWasmConfig ? ['cargo-wasm'] : [])],
|
|
724
848
|
options: {
|
|
@@ -739,7 +863,6 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
739
863
|
},
|
|
740
864
|
};
|
|
741
865
|
}
|
|
742
|
-
const hasTestTsconfig = existsSync(join(absoluteProjectRoot, 'tsconfig.test.json'));
|
|
743
866
|
if (hasTestTsconfig) {
|
|
744
867
|
targets['typecheck-tests'] = {
|
|
745
868
|
executor: 'nx:run-commands',
|
|
@@ -761,7 +884,7 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
761
884
|
};
|
|
762
885
|
const inferredTestWatchCommand = inferTestWatchCommand(packageJson);
|
|
763
886
|
if (inferredTestWatchCommand) {
|
|
764
|
-
targets['test
|
|
887
|
+
targets['test-watch'] = {
|
|
765
888
|
executor: 'nx:run-commands',
|
|
766
889
|
continuous: true,
|
|
767
890
|
dependsOn: ['typecheck-tests'],
|
|
@@ -1715,7 +1838,7 @@ function classifyPackageLocalBuildOutputs(packageJson) {
|
|
|
1715
1838
|
const targets = packageJson.nx?.targets;
|
|
1716
1839
|
const targetNames = isRecord(targets) ? Object.keys(targets) : [];
|
|
1717
1840
|
return {
|
|
1718
|
-
ordinary: targetNames.some(
|
|
1841
|
+
ordinary: targetNames.some(isBuildOutputTargetName),
|
|
1719
1842
|
platform: targetNames.some((targetName) => PLATFORM_TARGET_GLOBS.some((glob) => targetName.endsWith(glob.slice(1)))),
|
|
1720
1843
|
};
|
|
1721
1844
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"managed-assets.d.ts","sourceRoot":"","sources":["../src/managed-assets.ts"],"names":[],"mappings":"AAEA,kFAAkF;AAClF,eAAO,MAAM,iBAAiB,QAAyD,CAAC"}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import type { NonEmptyArray, PackageCargoCredentialsConfig, PackagePrivateNpmConfig, PackageRemoteCacheConfig, PackageSmooGithub, PackageSmooGithubEnvironments, PackageSourceCheckoutConfig } from '../workspace-manifest.js';
|
|
2
|
+
export declare enum CiWorkflowStepKind {
|
|
3
|
+
Checkout = "checkout",
|
|
4
|
+
SourceCheckouts = "source-checkouts",
|
|
5
|
+
SetupDevenv = "setup-devenv",
|
|
6
|
+
CargoCredentials = "cargo-credentials",
|
|
7
|
+
SetNxShas = "set-nx-shas",
|
|
8
|
+
RestoreNxCache = "restore-nx-cache",
|
|
9
|
+
Build = "build",
|
|
10
|
+
BrowserTests = "browser-tests",
|
|
11
|
+
Lint = "lint",
|
|
12
|
+
UnitTests = "unit-tests",
|
|
13
|
+
CrossToolchainPreflight = "cross-toolchain-preflight",
|
|
14
|
+
CrossTestArchives = "cross-test-archives",
|
|
15
|
+
UploadCrossTestArchives = "upload-cross-test-archives",
|
|
16
|
+
DownloadCrossTestArchives = "download-cross-test-archives",
|
|
17
|
+
CrossTests = "cross-tests",
|
|
18
|
+
ManagedFilesCheck = "managed-files-check",
|
|
19
|
+
ManagedFilesDispatch = "managed-files-dispatch",
|
|
20
|
+
Deploy = "deploy",
|
|
21
|
+
SaveNxCache = "save-nx-cache",
|
|
22
|
+
UploadTraceDbs = "upload-trace-dbs",
|
|
23
|
+
SaveNixDevenv = "save-nix-devenv"
|
|
24
|
+
}
|
|
25
|
+
export interface CiWorkflowStep {
|
|
26
|
+
kind: CiWorkflowStepKind;
|
|
27
|
+
name: string;
|
|
28
|
+
number: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* What a deploy step needs to authenticate, as declared configuration. Both
|
|
32
|
+
* workflow generators deploy production with the same credentials, so the
|
|
33
|
+
* declaration and its rendering live here once: a repo that declares
|
|
34
|
+
* `smoo.github.deploySecrets` gets them wherever a managed workflow deploys,
|
|
35
|
+
* not only on CI's stage deploy.
|
|
36
|
+
*/
|
|
37
|
+
export interface DeployStepSecretConfig {
|
|
38
|
+
deployProvider?: 'cloudflare';
|
|
39
|
+
/** Extra deploy-step secrets, env var name → repository secret name. */
|
|
40
|
+
deploySecrets?: Record<string, string>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* One foreign target triple's test archive: what the Linux job cross-builds and
|
|
44
|
+
* a native runner executes.
|
|
45
|
+
*
|
|
46
|
+
* Both fields are DERIVED, never hand-written: the triple comes from the cargo
|
|
47
|
+
* workspace's `[workspace.metadata.smoothbricks.test] cross-targets`, and the
|
|
48
|
+
* path is where the inferred `cargo-cross-test-archive-<triple>` target
|
|
49
|
+
* declares its output. That is why this is not a `smoo.github` key — a triple
|
|
50
|
+
* repeated in CI config could name an archive the graph cannot build, and the
|
|
51
|
+
* workflow would only find out on the runner.
|
|
52
|
+
*/
|
|
53
|
+
export interface CiCrossTestArchive {
|
|
54
|
+
triple: string;
|
|
55
|
+
/** Repository-relative path of the archive file, from the target's output. */
|
|
56
|
+
path: string;
|
|
57
|
+
}
|
|
58
|
+
export interface CiWorkflowDefinitionOptions extends DeployStepSecretConfig {
|
|
59
|
+
actionsProvider?: PackageSmooGithub['actionsProvider'];
|
|
60
|
+
deploy: boolean;
|
|
61
|
+
browserTests: boolean;
|
|
62
|
+
e2eDeployment: boolean;
|
|
63
|
+
/** The first entry is the branch whose pushes deploy the staging stage. */
|
|
64
|
+
pushBranches: NonEmptyArray<string>;
|
|
65
|
+
/** Default ubuntu-latest when omitted. */
|
|
66
|
+
runsOn?: string | string[];
|
|
67
|
+
/**
|
|
68
|
+
* Declared private-npm opt-in. Exposes the read token to the installing job
|
|
69
|
+
* before SetupDevenv so `.npmrc` `${TOKEN}` expansion can run, and skips
|
|
70
|
+
* fork PRs, which never receive secrets. The registry URL lives in `.npmrc`,
|
|
71
|
+
* not job env. Publish tokens never belong here.
|
|
72
|
+
*/
|
|
73
|
+
privateNpm?: PackagePrivateNpmConfig;
|
|
74
|
+
/**
|
|
75
|
+
* Declared sibling source checkouts (package.json `smoo.github.sourceCheckouts`).
|
|
76
|
+
* Cloned beside the main checkout before SetupDevenv so path dependencies
|
|
77
|
+
* resolve exactly as in the developer workspace. Absent means none.
|
|
78
|
+
*/
|
|
79
|
+
sourceCheckouts?: PackageSourceCheckoutConfig[];
|
|
80
|
+
/**
|
|
81
|
+
* Declared Cargo private-dependency credentials
|
|
82
|
+
* (package.json `smoo.github.cargoCredentials`). Registry tokens ride the
|
|
83
|
+
* job env; private git origins get a host-gated credential helper installed
|
|
84
|
+
* before SetupDevenv. Absent means no private Cargo fetch.
|
|
85
|
+
*/
|
|
86
|
+
cargoCredentials?: PackageCargoCredentialsConfig;
|
|
87
|
+
/**
|
|
88
|
+
* Declared self-hosted Nx remote cache (package.json `smoo.remoteCache`).
|
|
89
|
+
* Every job that runs Nx carries the server and the access token, so one
|
|
90
|
+
* cache serves the whole fleet. Absent means each runner caches locally.
|
|
91
|
+
*/
|
|
92
|
+
remoteCache?: PackageRemoteCacheConfig;
|
|
93
|
+
/** GitHub Environments: staging for the validate/e2e jobs, production for the production-on-push job. */
|
|
94
|
+
environments?: PackageSmooGithubEnvironments;
|
|
95
|
+
/** Secrets for the e2e-deployment step, env var name → repository secret name. */
|
|
96
|
+
e2eSecrets?: Record<string, string>;
|
|
97
|
+
/** Emit the production-on-push job (some project carries PRODUCTION_PUSH_DEPLOY_TAG). */
|
|
98
|
+
productionOnPush?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Cross-built test archives, one per foreign target triple the cargo
|
|
101
|
+
* workspace declares. The Linux job builds and uploads each one; a second job
|
|
102
|
+
* downloads the `*-apple-darwin` ones and EXECUTES them on `macosRunsOn`,
|
|
103
|
+
* which is how a cross compile gets proved by running rather than by linking.
|
|
104
|
+
*
|
|
105
|
+
* Empty or absent renders exactly what a repository without cross archives
|
|
106
|
+
* renders — no step, no job, no numbering shift.
|
|
107
|
+
*/
|
|
108
|
+
crossTestArchives?: readonly CiCrossTestArchive[];
|
|
109
|
+
/**
|
|
110
|
+
* macOS runner labels for the darwin execution job
|
|
111
|
+
* (`smoo.github.macosRunsOn`, the same labels the publish workflow's macOS
|
|
112
|
+
* legs use). Default macos-latest.
|
|
113
|
+
*
|
|
114
|
+
* A self-hosted label here is one specific machine. That machine being asleep
|
|
115
|
+
* does not skip the job: it queues, and the run FAILS on the job's
|
|
116
|
+
* `timeout-minutes`. That is the trade this opt-in buys — a red run when the
|
|
117
|
+
* Mac is unreachable, in exchange for the darwin binaries being tested by
|
|
118
|
+
* execution at all. `continue-on-error` would buy the green back by making
|
|
119
|
+
* the job unable to report anything, which is worse than not having it.
|
|
120
|
+
*/
|
|
121
|
+
macosRunsOn?: string | string[];
|
|
122
|
+
/**
|
|
123
|
+
* Declared Linux cross-platform producer (`smoo.github.platformProducer`):
|
|
124
|
+
* the toolchain preflight and the environment a foreign-target build needs on
|
|
125
|
+
* a Linux runner. The publish workflow already renders this declaration for
|
|
126
|
+
* its cross artifact job, so the cross test archive reuses it rather than
|
|
127
|
+
* carrying a second copy of one repository's SDK and linker setup.
|
|
128
|
+
*
|
|
129
|
+
* Rendered STEP-scoped here, never as job env: this environment turns the
|
|
130
|
+
* repository's native producers into cross producers, and Validate's other
|
|
131
|
+
* steps are host builds that must stay host builds.
|
|
132
|
+
*/
|
|
133
|
+
platformProducer?: PackageSmooGithub['platformProducer'];
|
|
134
|
+
}
|
|
135
|
+
export declare function defineCiWorkflow(options: CiWorkflowDefinitionOptions): CiWorkflowStep[];
|
|
136
|
+
export declare function renderCiWorkflowYaml(options: CiWorkflowDefinitionOptions): string;
|
|
137
|
+
/** Job env for `.npmrc` token expansion. Registry URL is not a GitHub variable. */
|
|
138
|
+
export declare function privateNpmReadTokenJobEnv(options: Pick<CiWorkflowDefinitionOptions, 'privateNpm'>): string;
|
|
139
|
+
/**
|
|
140
|
+
* One clone command per declared sibling source, pinned to its configured
|
|
141
|
+
* ref. The step's `if` keeps fork PRs — which receive no secrets — from
|
|
142
|
+
* touching source-read credentials, and their builds would lack the private
|
|
143
|
+
* siblings anyway. The clone URL stays clean: authorization rides per git
|
|
144
|
+
* command through `GIT_CONFIG_*` environment config whose
|
|
145
|
+
* `http.<origin>.extraheader` key names the exact origin, so the token never
|
|
146
|
+
* reaches argv, a file, the sibling's stored `.git/config`, or any other
|
|
147
|
+
* host. The token itself is only ever a shell expansion of the step env.
|
|
148
|
+
*/
|
|
149
|
+
export declare function sourceCheckoutsStepLines(step: CiWorkflowStep, checkouts: readonly PackageSourceCheckoutConfig[]): string[];
|
|
150
|
+
/** Mechanism errors surface at managed-file render time, never inside CI. */
|
|
151
|
+
export declare function normalizeSourceCheckout(config: PackageSourceCheckoutConfig): PackageSourceCheckoutConfig;
|
|
152
|
+
/**
|
|
153
|
+
* Job env lines carrying the declared Nx remote cache. The pair rides the job
|
|
154
|
+
* env rather than a step because every Nx invocation in the job — build, lint,
|
|
155
|
+
* tests, deploy — reads it, and Nx enables the cache on a nonempty server
|
|
156
|
+
* alone: an empty or absent token would make it authenticate with nothing and
|
|
157
|
+
* fail every task on 401, which is why the job carries the same fork-PR gate
|
|
158
|
+
* as a private dependency install (see `renderCiWorkflowHeader`).
|
|
159
|
+
*
|
|
160
|
+
* A declared `internalServer` is the address managed runners use, exactly as a
|
|
161
|
+
* git origin's `internalMirror` is: both say this repository's runners sit
|
|
162
|
+
* inside that network, and shells outside it keep the public origin.
|
|
163
|
+
* Mechanism errors surface at managed-file render time, never inside CI.
|
|
164
|
+
*/
|
|
165
|
+
export declare function remoteCacheJobEnvLines(config: PackageRemoteCacheConfig | undefined): string;
|
|
166
|
+
/** Mechanism errors surface at managed-file render time, never inside CI. */
|
|
167
|
+
export declare function normalizeRemoteCache(config: PackageRemoteCacheConfig): PackageRemoteCacheConfig;
|
|
168
|
+
/**
|
|
169
|
+
* Job env lines carrying the declared Cargo credential secrets. Both registry
|
|
170
|
+
* tokens and git-origin tokens ride the job env so the credential helper is
|
|
171
|
+
* still in scope when cargo spawns git much later in the build. Fork PRs
|
|
172
|
+
* receive empty values and skip the helper step, so nothing answers for a
|
|
173
|
+
* private origin there.
|
|
174
|
+
*/
|
|
175
|
+
export declare function cargoCredentialJobEnvLines(config: PackageCargoCredentialsConfig | undefined): string;
|
|
176
|
+
/**
|
|
177
|
+
* The credential-transport step preflights every declared token, then writes a
|
|
178
|
+
* host-gated helper script into `$RUNNER_TEMP` for git origins and points the
|
|
179
|
+
* per-process `GIT_CONFIG_*` environment at it through GITHUB_ENV, plus
|
|
180
|
+
* `CARGO_NET_GIT_FETCH_WITH_CLI` so Cargo shells out to git. Runners whose
|
|
181
|
+
* egress requires a proxy export it as `HTTP(S)_PROXY`, which cargo honors
|
|
182
|
+
* natively but git never reads, so the step mirrors it into git config or
|
|
183
|
+
* Cargo git fetches bypass the proxy and fail to connect. Origins with an
|
|
184
|
+
* `internalMirror` are rewritten to the mirror with `url.<mirror>.insteadOf`
|
|
185
|
+
* and the helper answers the same credential for the mirror's host, since git
|
|
186
|
+
* passes helpers the rewritten URL. The helper reads the environment at call
|
|
187
|
+
* time and answers only for declared origins. Declared `sshOrigins` rewrite
|
|
188
|
+
* onto the same mirror and stay credential-free: the rewrite happens before
|
|
189
|
+
* transport, so git only ever asks for the mirror, and an SSH pin the runner
|
|
190
|
+
* has no key for fails loudly instead of collecting a token.
|
|
191
|
+
* Mechanism errors surface at managed-file render time, never inside CI.
|
|
192
|
+
*/
|
|
193
|
+
export declare function cargoCredentialStepLines(step: CiWorkflowStep, config: PackageCargoCredentialsConfig): string[];
|
|
194
|
+
/** Mechanism errors surface at managed-file render time, never inside CI. */
|
|
195
|
+
export declare function normalizeCargoCredentials(config: PackageCargoCredentialsConfig): PackageCargoCredentialsConfig;
|
|
196
|
+
/**
|
|
197
|
+
* The same-repo gate as prettier folds it: the raw single line exceeds the
|
|
198
|
+
* print width, so the generator emits the folded form itself to keep the
|
|
199
|
+
* checked-in managed output byte-identical across regeneration and hooks.
|
|
200
|
+
*/
|
|
201
|
+
export declare const SAME_REPO_GATE_FOLDED: string[];
|
|
202
|
+
/**
|
|
203
|
+
* The step-scoped `env:` block for a deploy step. Step scope is the property
|
|
204
|
+
* being rendered, not an accident of indentation: job env would hand the
|
|
205
|
+
* deployment credentials to every other step in that job — checkout, setup,
|
|
206
|
+
* build, and in the publish workflow the pending-release repair and the npm
|
|
207
|
+
* publish itself.
|
|
208
|
+
*
|
|
209
|
+
* An explicit declaration wins over the provider default, so a repo whose
|
|
210
|
+
* Cloudflare credentials live under different repository secret names says so
|
|
211
|
+
* once in `deploySecrets` instead of being overridden here.
|
|
212
|
+
*/
|
|
213
|
+
export declare function deployStepSecretEnvLines(config: DeployStepSecretConfig): string[];
|
|
214
|
+
export declare function artifactStepLines(provider: PackageSmooGithub['actionsProvider'], name: string, kind: 'upload' | 'download', inputs: readonly string[], condition?: string): string[];
|
|
215
|
+
//# sourceMappingURL=ci-workflow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ci-workflow.d.ts","sourceRoot":"","sources":["../../src/managed-files/ci-workflow.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,aAAa,EACb,6BAA6B,EAE7B,uBAAuB,EACvB,wBAAwB,EACxB,iBAAiB,EACjB,6BAA6B,EAC7B,2BAA2B,EAC5B,MAAM,0BAA0B,CAAC;AAGlC,oBAAY,kBAAkB;IAC5B,QAAQ,aAAa;IACrB,eAAe,qBAAqB;IACpC,WAAW,iBAAiB;IAC5B,gBAAgB,sBAAsB;IACtC,SAAS,gBAAgB;IACzB,cAAc,qBAAqB;IACnC,KAAK,UAAU;IACf,YAAY,kBAAkB;IAC9B,IAAI,SAAS;IACb,SAAS,eAAe;IACxB,uBAAuB,8BAA8B;IACrD,iBAAiB,wBAAwB;IACzC,uBAAuB,+BAA+B;IACtD,yBAAyB,iCAAiC;IAC1D,UAAU,gBAAgB;IAC1B,iBAAiB,wBAAwB;IACzC,oBAAoB,2BAA2B;IAC/C,MAAM,WAAW;IACjB,WAAW,kBAAkB;IAC7B,cAAc,qBAAqB;IACnC,aAAa,oBAAoB;CAClC;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,kBAAkB,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,sBAAsB;IACrC,cAAc,CAAC,EAAE,YAAY,CAAC;IAC9B,wEAAwE;IACxE,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACxC;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,8EAA8E;IAC9E,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,2BAA4B,SAAQ,sBAAsB;IACzE,eAAe,CAAC,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;IACvD,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,OAAO,CAAC;IACtB,aAAa,EAAE,OAAO,CAAC;IACvB,2EAA2E;IAC3E,YAAY,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACpC,0CAA0C;IAC1C,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC3B;;;;;OAKG;IACH,UAAU,CAAC,EAAE,uBAAuB,CAAC;IACrC;;;;OAIG;IACH,eAAe,CAAC,EAAE,2BAA2B,EAAE,CAAC;IAChD;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,6BAA6B,CAAC;IACjD;;;;OAIG;IACH,WAAW,CAAC,EAAE,wBAAwB,CAAC;IACvC,yGAAyG;IACzG,YAAY,CAAC,EAAE,6BAA6B,CAAC;IAC7C,kFAAkF;IAClF,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,yFAAyF;IACzF,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;;;;;OAQG;IACH,iBAAiB,CAAC,EAAE,SAAS,kBAAkB,EAAE,CAAC;IAClD;;;;;;;;;;;OAWG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAChC;;;;;;;;;;OAUG;IACH,gBAAgB,CAAC,EAAE,iBAAiB,CAAC,kBAAkB,CAAC,CAAC;CAC1D;AAID,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,2BAA2B,GAAG,cAAc,EAAE,CAiDvF;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,2BAA2B,GAAG,MAAM,CASjF;AAkED,mFAAmF;AACnF,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,IAAI,CAAC,2BAA2B,EAAE,YAAY,CAAC,GAAG,MAAM,CAM1G;AAsPD;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,cAAc,EACpB,SAAS,EAAE,SAAS,2BAA2B,EAAE,GAChD,MAAM,EAAE,CA+BV;AAED,6EAA6E;AAC7E,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,2BAA2B,GAAG,2BAA2B,CA8BxG;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,wBAAwB,GAAG,SAAS,GAAG,MAAM,CAS3F;AAED,6EAA6E;AAC7E,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,wBAAwB,GAAG,wBAAwB,CAgB/F;AA+BD;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,6BAA6B,GAAG,SAAS,GAAG,MAAM,CASpG;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,6BAA6B,GAAG,MAAM,EAAE,CAyG9G;AAqCD,6EAA6E;AAC7E,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,6BAA6B,GAAG,6BAA6B,CAkC9G;AAqGD;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,UAIjC,CAAC;AAiCF;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,sBAAsB,GAAG,MAAM,EAAE,CAMjF;AAmRD,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,EAC9C,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,QAAQ,GAAG,UAAU,EAC3B,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,SAAS,SAAc,GACtB,MAAM,EAAE,CAmBV"}
|