@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
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { lstatSync, realpathSync, statSync } from 'node:fs';
|
|
2
|
+
import { isAbsolute, relative, resolve, sep } from 'node:path';
|
|
3
|
+
import { isManagedTarget, type ManagedPathInfo } from './tree.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Small filesystem boundary for permissions and links, which Nx Tree cannot
|
|
7
|
+
* read. Never reads content and never writes. In-memory generator tests supply
|
|
8
|
+
* these facts directly; real-filesystem tests exercise this boundary separately.
|
|
9
|
+
*/
|
|
10
|
+
export function inspectManagedPaths(root: string, targets: readonly string[]): Map<string, ManagedPathInfo> {
|
|
11
|
+
const canonicalRoot = realpathSync(root);
|
|
12
|
+
return new Map(targets.map((target) => [target, inspectPath(canonicalRoot, target)]));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function inspectPath(root: string, target: string): ManagedPathInfo {
|
|
16
|
+
if (!isManagedTarget(target)) return { error: 'invalid managed path' };
|
|
17
|
+
const parts = target.split('/');
|
|
18
|
+
for (let i = 1; i < parts.length; i++) {
|
|
19
|
+
const parent = lstatSync(resolve(root, ...parts.slice(0, i)), { throwIfNoEntry: false });
|
|
20
|
+
if (parent === undefined) return {};
|
|
21
|
+
if (!parent.isDirectory())
|
|
22
|
+
return { error: 'parent path is not a regular directory (symlink parents are not managed)' };
|
|
23
|
+
}
|
|
24
|
+
const path = resolve(root, target);
|
|
25
|
+
const info = lstatSync(path, { throwIfNoEntry: false });
|
|
26
|
+
if (info === undefined) return {};
|
|
27
|
+
if (!info.isSymbolicLink()) {
|
|
28
|
+
return info.isFile() ? { executable: (info.mode & 0o100) !== 0 } : { error: 'target is not a regular file' };
|
|
29
|
+
}
|
|
30
|
+
let destination: string;
|
|
31
|
+
try {
|
|
32
|
+
destination = realpathSync(path);
|
|
33
|
+
} catch {
|
|
34
|
+
return { error: 'symlink is broken, cyclic or inaccessible; refusing to follow it' };
|
|
35
|
+
}
|
|
36
|
+
const fromRoot = relative(root, destination);
|
|
37
|
+
if (isAbsolute(fromRoot) || fromRoot === '..' || fromRoot.startsWith(`..${sep}`)) {
|
|
38
|
+
return { error: 'symlink resolves outside the workspace' };
|
|
39
|
+
}
|
|
40
|
+
const linked = statSync(destination);
|
|
41
|
+
return linked.isFile()
|
|
42
|
+
? { symlink: true, executable: (linked.mode & 0o100) !== 0 }
|
|
43
|
+
: { error: 'symlink does not resolve to a regular file' };
|
|
44
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/* biome-ignore-all lint/suspicious/noTemplateCurlyInString: GitHub Actions expressions are emitted literally. */
|
|
2
|
+
|
|
3
|
+
import { renderRunsOnLine } from './github-runs-on.js';
|
|
4
|
+
|
|
5
|
+
export interface PrPreviewCleanupWorkflowOptions {
|
|
6
|
+
runsOn?: string | string[];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function renderPrPreviewCleanupWorkflowYaml(options: PrPreviewCleanupWorkflowOptions = {}): string {
|
|
10
|
+
return `name: PR Preview Cleanup
|
|
11
|
+
|
|
12
|
+
on:
|
|
13
|
+
pull_request:
|
|
14
|
+
types: [closed]
|
|
15
|
+
|
|
16
|
+
permissions:
|
|
17
|
+
contents: read
|
|
18
|
+
|
|
19
|
+
jobs:
|
|
20
|
+
cleanup:
|
|
21
|
+
name: Cleanup PR environment
|
|
22
|
+
if: github.event.pull_request.head.repo.full_name == github.repository
|
|
23
|
+
${renderRunsOnLine(options.runsOn)}
|
|
24
|
+
timeout-minutes: 15
|
|
25
|
+
defaults:
|
|
26
|
+
run:
|
|
27
|
+
working-directory: tooling/direnv
|
|
28
|
+
steps:
|
|
29
|
+
- name: Checkout
|
|
30
|
+
uses: actions/checkout@v6.0.2
|
|
31
|
+
with:
|
|
32
|
+
filter: blob:none
|
|
33
|
+
fetch-depth: 1
|
|
34
|
+
|
|
35
|
+
- name: Setup Nix/devenv
|
|
36
|
+
uses: ./.github/actions/setup-devenv
|
|
37
|
+
|
|
38
|
+
- name: Cleanup PR environment
|
|
39
|
+
env:
|
|
40
|
+
CLOUDFLARE_API_TOKEN: \${{ secrets.CLOUDFLARE_API_TOKEN }}
|
|
41
|
+
CLOUDFLARE_ACCOUNT_ID: \${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
|
42
|
+
run: smoo wrangler cleanup-pr --pr \${{ github.event.pull_request.number }}
|
|
43
|
+
`;
|
|
44
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { PackageJson, PackagePrivateNpmConfig } from '../workspace-manifest.js';
|
|
2
|
+
import { isPublishablePackage } from '../workspace-package-policy.js';
|
|
3
|
+
|
|
4
|
+
/** Committed npmrc values only; workflow generation must not depend on a user's home. */
|
|
5
|
+
export function npmrcValueFromText(text: string, key: string): string | undefined {
|
|
6
|
+
for (const line of text.split(/\r?\n/)) {
|
|
7
|
+
const trimmed = line.trim();
|
|
8
|
+
if (trimmed.startsWith('#') || trimmed.startsWith(';')) continue;
|
|
9
|
+
const separator = trimmed.indexOf('=');
|
|
10
|
+
if (separator > 0 && trimmed.slice(0, separator).trim() === key) return trimmed.slice(separator + 1).trim();
|
|
11
|
+
}
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function npmrcTokenEnvFromText(text: string, scope: string): string | undefined {
|
|
16
|
+
const registry = npmrcValueFromText(text, `${scope}:registry`);
|
|
17
|
+
if (!registry) return undefined;
|
|
18
|
+
let url: URL;
|
|
19
|
+
try {
|
|
20
|
+
url = new URL(registry);
|
|
21
|
+
} catch {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
const pathname = url.pathname.endsWith('/') ? url.pathname : `${url.pathname}/`;
|
|
25
|
+
return /^\$\{([A-Za-z_][A-Za-z0-9_]*)\}$/.exec(
|
|
26
|
+
npmrcValueFromText(text, `//${url.host}${pathname}:_authToken`) ?? '',
|
|
27
|
+
)?.[1];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Resolve workflow credential NAMES without obtaining, interpolating, or persisting any secret. */
|
|
31
|
+
export function privateNpmWorkflowConfig(
|
|
32
|
+
declared: PackagePrivateNpmConfig | undefined,
|
|
33
|
+
root: PackageJson,
|
|
34
|
+
packages: readonly PackageJson[],
|
|
35
|
+
npmrc: string,
|
|
36
|
+
): PackagePrivateNpmConfig | undefined {
|
|
37
|
+
if (!declared) return undefined;
|
|
38
|
+
const inScope = (name: string) => name === declared.scope || name.startsWith(`${declared.scope}/`);
|
|
39
|
+
const consumes = [root, ...packages].some((pkg) =>
|
|
40
|
+
[pkg.dependencies, pkg.devDependencies, pkg.peerDependencies, pkg.optionalDependencies].some((deps) =>
|
|
41
|
+
Object.entries(deps ?? {}).some(([name, spec]) => inScope(name) && !/^(workspace|link|file):/.test(spec)),
|
|
42
|
+
),
|
|
43
|
+
);
|
|
44
|
+
const publishes = packages.some(
|
|
45
|
+
(pkg) =>
|
|
46
|
+
pkg.name &&
|
|
47
|
+
pkg.version &&
|
|
48
|
+
inScope(pkg.name) &&
|
|
49
|
+
isPublishablePackage({ private: pkg.private === true, tags: pkg.nx?.tags ?? [] }) &&
|
|
50
|
+
pkg.nx?.tags?.includes('npm:private'),
|
|
51
|
+
);
|
|
52
|
+
if (!consumes && !publishes) return undefined;
|
|
53
|
+
const npmrcEnv = npmrcTokenEnvFromText(npmrc, declared.scope);
|
|
54
|
+
const readTokenEnv = declared.readTokenEnv ?? (consumes ? npmrcEnv : undefined);
|
|
55
|
+
const publishTokenEnv = publishes ? (declared.publishTokenEnv ?? npmrcEnv) : undefined;
|
|
56
|
+
if (!readTokenEnv && !publishTokenEnv) return undefined;
|
|
57
|
+
return {
|
|
58
|
+
scope: declared.scope,
|
|
59
|
+
...(readTokenEnv ? { readTokenEnv } : {}),
|
|
60
|
+
...(publishTokenEnv ? { publishTokenEnv } : {}),
|
|
61
|
+
};
|
|
62
|
+
}
|