fg-devkit 1.12.6 → 1.12.8

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,64 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Align Node toolchain files in the current repository with policy.toolchain.node.
4
+ *
5
+ * Updates .nvmrc (creates if missing), .node-version (only if present), package.json engines.node
6
+ * (when policy defines engines), Dockerfile/Dockerfile.local base images, Jenkinsfile agent image,
7
+ * and GitHub Actions workflow node-version fields.
8
+ *
9
+ * Policy path: first CLI argument, or default under fg-devkit/configs/.
10
+ *
11
+ * Usage:
12
+ * pnpm exec fg-devkit sync-node-toolchain [policy-file] [--dry-run]
13
+ */
14
+
15
+ import fs from 'node:fs'
16
+ import path from 'node:path'
17
+ import { fileURLToPath } from 'node:url'
18
+
19
+ import {
20
+ collectNodeToolchainPolicyViolations,
21
+ resolveExpectedNodePolicy,
22
+ } from './dependency-policy-toolchain.mjs'
23
+ import { syncNodeToolchainInRepo } from './node-toolchain-sync.mjs'
24
+ import { resolveDependencyPolicyPath } from './resolve-dependency-policy-path.mjs'
25
+
26
+ const cwd = process.cwd()
27
+ const scriptDir = path.dirname(fileURLToPath(import.meta.url))
28
+ const fgDevkitRoot = path.resolve(scriptDir, '..')
29
+ const cliArgs = process.argv.slice(2).filter((a) => a !== '--dry-run')
30
+ const dryRun = process.argv.includes('--dry-run')
31
+ const policyPath = resolveDependencyPolicyPath(scriptDir, cwd, ['node', 'sync-node-toolchain.mjs', ...cliArgs])
32
+
33
+ if (!fs.existsSync(policyPath)) {
34
+ console.error(`[sync-node-toolchain] Could not find dependency policy: ${policyPath}`)
35
+ process.exit(1)
36
+ }
37
+
38
+ const policy = JSON.parse(fs.readFileSync(policyPath, 'utf8'))
39
+ const policyErrors = collectNodeToolchainPolicyViolations(policy)
40
+ if (policyErrors.length > 0) {
41
+ console.error('[sync-node-toolchain] Invalid node toolchain policy:')
42
+ for (const err of policyErrors) {
43
+ console.error(`- ${err}`)
44
+ }
45
+ process.exit(1)
46
+ }
47
+
48
+ if (!resolveExpectedNodePolicy(policy, fgDevkitRoot)) {
49
+ console.log('[sync-node-toolchain] No toolchain.node policy defined; nothing to sync')
50
+ process.exit(0)
51
+ }
52
+
53
+ const changes = syncNodeToolchainInRepo(cwd, policy, { dryRun, fgDevkitRoot })
54
+
55
+ if (changes.length === 0) {
56
+ console.log('[sync-node-toolchain] Node toolchain already matches policy')
57
+ process.exit(0)
58
+ }
59
+
60
+ const prefix = dryRun ? '[sync-node-toolchain] DRY RUN ' : '[sync-node-toolchain] '
61
+ console.log(`${prefix}Updated Node toolchain:`)
62
+ for (const change of changes) {
63
+ console.log(`- ${change}`)
64
+ }
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Align pnpm packageManager and all pnpm@x.y.z pins in the current repository with policy.toolchain.packageManager.
4
+ *
5
+ * Usage:
6
+ * pnpm exec fg-devkit sync-pnpm-toolchain [policy-file] [--dry-run]
7
+ */
8
+
9
+ import fs from 'node:fs'
10
+ import path from 'node:path'
11
+ import { fileURLToPath } from 'node:url'
12
+
13
+ import {
14
+ collectToolchainPolicyViolations,
15
+ resolveExpectedPackageManager,
16
+ } from './dependency-policy-toolchain.mjs'
17
+ import { syncPnpmToolchainInRepo } from './pnpm-toolchain-sync.mjs'
18
+ import { resolveDependencyPolicyPath } from './resolve-dependency-policy-path.mjs'
19
+
20
+ const cwd = process.cwd()
21
+ const scriptDir = path.dirname(fileURLToPath(import.meta.url))
22
+ const fgDevkitRoot = path.resolve(scriptDir, '..')
23
+ const cliArgs = process.argv.slice(2).filter((a) => a !== '--dry-run')
24
+ const dryRun = process.argv.includes('--dry-run')
25
+ const policyPath = resolveDependencyPolicyPath(scriptDir, cwd, ['node', 'sync-pnpm-toolchain.mjs', ...cliArgs])
26
+
27
+ if (!fs.existsSync(policyPath)) {
28
+ console.error(`[sync-pnpm-toolchain] Could not find dependency policy: ${policyPath}`)
29
+ process.exit(1)
30
+ }
31
+
32
+ const policy = JSON.parse(fs.readFileSync(policyPath, 'utf8'))
33
+ const policyErrors = collectToolchainPolicyViolations(policy)
34
+ if (policyErrors.length > 0) {
35
+ console.error('[sync-pnpm-toolchain] Invalid toolchain policy:')
36
+ for (const err of policyErrors) {
37
+ console.error(`- ${err}`)
38
+ }
39
+ process.exit(1)
40
+ }
41
+
42
+ const packageManager = resolveExpectedPackageManager(policy, fgDevkitRoot)
43
+ if (!packageManager) {
44
+ console.log('[sync-pnpm-toolchain] No toolchain.packageManager policy defined; nothing to sync')
45
+ process.exit(0)
46
+ }
47
+
48
+ const changes = syncPnpmToolchainInRepo(cwd, packageManager, { dryRun })
49
+
50
+ if (changes.length === 0) {
51
+ console.log('[sync-pnpm-toolchain] pnpm toolchain already matches policy')
52
+ process.exit(0)
53
+ }
54
+
55
+ const prefix = dryRun ? '[sync-pnpm-toolchain] DRY RUN ' : '[sync-pnpm-toolchain] '
56
+ console.log(`${prefix}Updated pnpm toolchain:`)
57
+ for (const change of changes) {
58
+ console.log(`- ${change}`)
59
+ }
@@ -15,9 +15,12 @@ import { fileURLToPath } from 'node:url'
15
15
  import { resolveDependencyPolicyPath } from './resolve-dependency-policy-path.mjs'
16
16
  import {
17
17
  extractPnpmVersion,
18
+ resolveExpectedNodePolicy,
18
19
  resolveExpectedPackageManager,
19
20
  syncPolicyToolchainFromFgDevkit,
20
21
  } from './dependency-policy-toolchain.mjs'
22
+ import { syncDockerfileNodeImages } from './node-toolchain-sync.mjs'
23
+ import { syncDockerfilePnpmVersion } from './pnpm-toolchain-sync.mjs'
21
24
 
22
25
  /**
23
26
  * @param {{ fgDevkitRoot: string, policyPath: string }} options
@@ -75,12 +78,16 @@ export function syncScaffoldVueDepsFromPolicy(options) {
75
78
  const pnpmVersion = extractPnpmVersion(expectedPackageManager)
76
79
  if (pnpmVersion && fs.existsSync(dockerfilePath)) {
77
80
  const dockerfile = fs.readFileSync(dockerfilePath, 'utf8')
78
- const updatedDockerfile = dockerfile.replace(
79
- /corepack prepare pnpm@[^\s]+ --activate/,
80
- `corepack prepare pnpm@${pnpmVersion} --activate`,
81
+ const { content: pnpmUpdated, changed: pnpmChanged } = syncDockerfilePnpmVersion(
82
+ dockerfile,
83
+ pnpmVersion,
81
84
  )
82
- if (updatedDockerfile !== dockerfile) {
83
- fs.writeFileSync(dockerfilePath, updatedDockerfile)
85
+ const nodePolicy = resolveExpectedNodePolicy(policy, fgDevkitRoot)
86
+ const finalDockerfile = nodePolicy
87
+ ? syncDockerfileNodeImages(pnpmUpdated, nodePolicy.nvmrc, nodePolicy.dockerTag).content
88
+ : pnpmUpdated
89
+ if (pnpmChanged || finalDockerfile !== dockerfile) {
90
+ fs.writeFileSync(dockerfilePath, finalDockerfile)
84
91
  console.log('[sync-scaffold-vue-deps] Updated', dockerfilePath)
85
92
  }
86
93
  }
@@ -1,16 +0,0 @@
1
- FROM node:22-bookworm AS build
2
- WORKDIR /src
3
- COPY . /src
4
- RUN corepack enable && corepack prepare pnpm@11.9.0 --activate
5
- RUN pnpm install
6
- RUN pnpm build
7
-
8
- FROM nginx
9
- RUN echo "daemon off;" >> /etc/nginx/nginx.conf
10
- ENV CONFIG_FILE_PATH=/usr/share/nginx/html/config.json
11
- COPY --from=build /src/dist /usr/share/nginx/html
12
- COPY nginx/*.conf /etc/nginx/conf.d/
13
- COPY start-container.sh /usr/local/bin/start-container
14
- RUN chmod +x /usr/local/bin/start-container
15
- ENTRYPOINT ["start-container"]
16
- CMD ["nginx"]