@catladder/cli 0.0.0-next-d71e41ba → 0.0.0-next-b3e567e8
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/dist/apps/cli/src/scripts/generateCliSkillReference.js +3 -2
- package/dist/apps/cli/src/scripts/generateCliSkillReference.js.map +1 -1
- package/dist/bundles/catenv/index.js +546 -205
- package/dist/bundles/cli/index.js +546 -205
- package/dist/bundles/runner-images/docker-build/scripts/ensureNodeDockerfile +8 -1
- package/dist/bundles/runner-images/jobs-default/Dockerfile +4 -0
- package/dist/bundles/skills/catladder-builds/SKILL.md +19 -3
- package/dist/bundles/skills/catladder-builds/references/build-types.md +6 -4
- package/dist/bundles/skills/catladder-cli/references/commands.md +3 -2
- package/dist/bundles/skills/catladder-config/SKILL.md +5 -0
- package/dist/bundles/skills/catladder-deploys/SKILL.md +1 -1
- package/dist/bundles/skills/catladder-deploys/references/deploy-types.md +2 -2
- package/dist/bundles/skills/catladder-pipelines/SKILL.md +3 -1
- package/dist/packages/pipeline/src/build/base/createAppBuildJob.js +2 -2
- package/dist/packages/pipeline/src/build/base/createAppBuildJob.js.map +1 -1
- package/dist/packages/pipeline/src/build/index.d.ts +3 -3
- package/dist/packages/pipeline/src/build/index.js +16 -11
- package/dist/packages/pipeline/src/build/index.js.map +1 -1
- package/dist/packages/pipeline/src/build/node/buildJob.js +49 -8
- package/dist/packages/pipeline/src/build/node/buildJob.js.map +1 -1
- package/dist/packages/pipeline/src/build/node/cache.d.ts +5 -0
- package/dist/packages/pipeline/src/build/node/cache.js +58 -19
- package/dist/packages/pipeline/src/build/node/cache.js.map +1 -1
- package/dist/packages/pipeline/src/build/node/meteor.js +9 -4
- package/dist/packages/pipeline/src/build/node/meteor.js.map +1 -1
- package/dist/packages/pipeline/src/build/node/packageManagerInstall.d.ts +14 -0
- package/dist/packages/pipeline/src/build/node/packageManagerInstall.js +145 -0
- package/dist/packages/pipeline/src/build/node/packageManagerInstall.js.map +1 -0
- package/dist/packages/pipeline/src/build/node/testJob.js +9 -11
- package/dist/packages/pipeline/src/build/node/testJob.js.map +1 -1
- package/dist/packages/pipeline/src/context/createComponentContext.js +3 -2
- package/dist/packages/pipeline/src/context/createComponentContext.js.map +1 -1
- package/dist/packages/pipeline/src/context/createWorkspaceContext.js +3 -2
- package/dist/packages/pipeline/src/context/createWorkspaceContext.js.map +1 -1
- package/dist/packages/pipeline/src/deploy/custom/deployJob.js +7 -6
- package/dist/packages/pipeline/src/deploy/custom/deployJob.js.map +1 -1
- package/dist/packages/pipeline/src/deploy/pages/deployJob.js +6 -4
- package/dist/packages/pipeline/src/deploy/pages/deployJob.js.map +1 -1
- package/dist/packages/pipeline/src/deploy/types/custom.d.ts +7 -1
- package/dist/packages/pipeline/src/deploy/types/pages.d.ts +7 -1
- package/dist/packages/pipeline/src/pipeline/detectPackageManager.d.ts +18 -0
- package/dist/packages/pipeline/src/pipeline/detectPackageManager.js +76 -0
- package/dist/packages/pipeline/src/pipeline/detectPackageManager.js.map +1 -0
- package/dist/packages/pipeline/src/pipeline/packageManager.d.ts +1 -1
- package/dist/packages/pipeline/src/pipeline/packageManager.js +43 -9
- package/dist/packages/pipeline/src/pipeline/packageManager.js.map +1 -1
- package/dist/packages/pipeline/src/pipeline/pnpm/pnpmUtils.d.ts +14 -0
- package/dist/packages/pipeline/src/pipeline/pnpm/pnpmUtils.js +93 -0
- package/dist/packages/pipeline/src/pipeline/pnpm/pnpmUtils.js.map +1 -0
- package/dist/packages/pipeline/src/types/config.d.ts +8 -1
- package/dist/packages/pipeline/src/types/context.d.ts +11 -3
- package/dist/packages/pipeline/src/types/context.js.map +1 -1
- package/dist/packages/pipeline/src/verify/createVerifyJobs.js +5 -5
- package/dist/packages/pipeline/src/verify/createVerifyJobs.js.map +1 -1
- package/dist/runner-images/docker-build/scripts/ensureNodeDockerfile +8 -1
- package/dist/runner-images/jobs-default/Dockerfile +4 -0
- package/dist/skills/catladder-builds/SKILL.md +19 -3
- package/dist/skills/catladder-builds/references/build-types.md +6 -4
- package/dist/skills/catladder-cli/references/commands.md +3 -2
- package/dist/skills/catladder-config/SKILL.md +5 -0
- package/dist/skills/catladder-deploys/SKILL.md +1 -1
- package/dist/skills/catladder-deploys/references/deploy-types.md +2 -2
- package/dist/skills/catladder-pipelines/SKILL.md +3 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/scripts/generateCliSkillReference.ts +3 -2
- package/dist/packages/pipeline/src/build/node/yarn.d.ts +0 -8
- package/dist/packages/pipeline/src/build/node/yarn.js +0 -78
- package/dist/packages/pipeline/src/build/node/yarn.js.map +0 -1
|
@@ -35,10 +35,17 @@ FROM node:$NODE_VERSION-alpine
|
|
|
35
35
|
$DOCKERFILE_ADDITIONS
|
|
36
36
|
|
|
37
37
|
RUN apk add --no-cache git curl
|
|
38
|
-
|
|
38
|
+
# package-manager setup (e.g. installing pnpm globally) and the
|
|
39
|
+
# workspace-file copy run as root: pnpm ADDs a tar whose extracted
|
|
40
|
+
# parent dirs come out root-owned (ADD --chown only covers the files),
|
|
41
|
+
# so it needs a root chown before the node user can write node_modules.
|
|
42
|
+
# The actual install below still runs as the unprivileged node user.
|
|
43
|
+
$DOCKER_SETUP_PACKAGE_MANAGER
|
|
39
44
|
|
|
40
45
|
$DOCKER_COPY_WORKSPACE_FILES
|
|
41
46
|
|
|
47
|
+
USER node
|
|
48
|
+
|
|
42
49
|
WORKDIR /app/$APP_DIR
|
|
43
50
|
|
|
44
51
|
$DOCKER_COPY_AND_INSTALL_APP
|
|
@@ -9,6 +9,10 @@ RUN rm /bin/sh && \
|
|
|
9
9
|
# set high timeout for yarn, see https://github.com/dhis2/notes/issues/29
|
|
10
10
|
RUN yarn config set network-timeout 600000 -g
|
|
11
11
|
|
|
12
|
+
# pnpm for projects using it (pnpm self-switches to the version pinned
|
|
13
|
+
# in the project's packageManager field)
|
|
14
|
+
RUN npm install -g pnpm
|
|
15
|
+
|
|
12
16
|
# install nvm && some common node versions
|
|
13
17
|
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash && \
|
|
14
18
|
source /root/.nvm/nvm.sh && \
|
|
@@ -28,11 +28,26 @@ components: {
|
|
|
28
28
|
Set `build: false` to disable building for a component (e.g. a
|
|
29
29
|
deploy-only or docker-tag component).
|
|
30
30
|
|
|
31
|
+
Node-family builds work with **yarn or pnpm**: catladder autodetects the
|
|
32
|
+
package manager (from the `packageManager` field in package.json or the
|
|
33
|
+
lockfile) and generates the matching install commands, caches and
|
|
34
|
+
default build/lint/test commands. Override with `packageManager:
|
|
35
|
+
"pnpm" | "yarn"` at the top level of `catladder.ts` if needed. The
|
|
36
|
+
`meteor` build type is yarn-only.
|
|
37
|
+
|
|
38
|
+
pnpm gotchas: dependency build scripts must be approved in
|
|
39
|
+
pnpm-workspace.yaml (`allowBuilds` map since pnpm 11,
|
|
40
|
+
`onlyBuiltDependencies` list on pnpm 10); pnpm runs the root
|
|
41
|
+
`prepare` script even during the production install in the docker
|
|
42
|
+
build — guard husky with `"prepare": "husky || true"`; `pnpm run`
|
|
43
|
+
prints a banner to stdout, so use `pnpm --silent run` in piped
|
|
44
|
+
commands.
|
|
45
|
+
|
|
31
46
|
## Build types
|
|
32
47
|
|
|
33
48
|
| Type | Use for | Notes |
|
|
34
49
|
|---|---|---|
|
|
35
|
-
| `node` | Node/JS apps (Next.js, Vite, plain node) | default
|
|
50
|
+
| `node` | Node/JS apps (Next.js, Vite, plain node) | default `<pm> build` + `<pm> start` (yarn or pnpm, autodetected); `docker` selects the runtime image |
|
|
36
51
|
| `rails` | Ruby on Rails apps | Cloud Native Buildpacks when there is no `Dockerfile`; Postgres test DB |
|
|
37
52
|
| `meteor` | Meteor apps | starts `node main.js` |
|
|
38
53
|
| `custom` | anything else | you provide the `jobImage` and `docker` config (both required) |
|
|
@@ -46,8 +61,9 @@ type: `build: { from: "web" }` (see workspace builds below).
|
|
|
46
61
|
- `buildCommand` — the build step (`string | string[] | null | false`;
|
|
47
62
|
`false`/`null` skips building).
|
|
48
63
|
- `startCommand` — how the app is started at runtime.
|
|
49
|
-
- `postInstall` — commands run after
|
|
50
|
-
e.g. for Yarn PnP where `package.json` postinstall
|
|
64
|
+
- `postInstall` — commands run after the package-manager install (node
|
|
65
|
+
family; needed e.g. for Yarn PnP where `package.json` postinstall
|
|
66
|
+
won't run).
|
|
51
67
|
- `lint` / `test` / `audit` — customize (`{ command, jobImage, … }`) or
|
|
52
68
|
set to `false` to disable that job.
|
|
53
69
|
- `artifactsPaths` / `artifactsExcludePaths` — extra build artifacts
|
|
@@ -10,7 +10,7 @@ generated pipeline files.
|
|
|
10
10
|
|---|---|---|
|
|
11
11
|
| `buildCommand` | `string \| string[] \| null \| false` | build step; `false`/`null` skips it |
|
|
12
12
|
| `startCommand` | `string` | runtime start command |
|
|
13
|
-
| `postInstall` | `string \| string[]` | runs after
|
|
13
|
+
| `postInstall` | `string \| string[]` | runs after the package-manager install (node family) |
|
|
14
14
|
| `lint` / `test` / `audit` | `false \| TestJobCustom` | customize or disable the job |
|
|
15
15
|
| `artifactsPaths` | `string[]` | extra artifacts (`dist`, `.next` always included) |
|
|
16
16
|
| `artifactsExcludePaths` | `string[]` | artifact excludes |
|
|
@@ -29,8 +29,9 @@ generated pipeline files.
|
|
|
29
29
|
## Per-type options & defaults
|
|
30
30
|
|
|
31
31
|
### `node`
|
|
32
|
-
-
|
|
33
|
-
-
|
|
32
|
+
- Works with yarn **and pnpm** — the package manager is autodetected (`packageManager` field / lockfile), overridable via top-level `packageManager: "pnpm" | "yarn"` in `catladder.ts`.
|
|
33
|
+
- `docker?` — built-in node image `{ type: "node", yarnRebuildEnabled?: boolean (default true, yarn berry only), additionsBegin?: string[], additionsEnd?: string[] }`, or a custom docker config.
|
|
34
|
+
- Defaults: `buildCommand: "<pm> build"`, `startCommand: "<pm> start"` (`yarn`/`pnpm` per detection), artifacts `["dist", ".next"]`, excludes `[".next/cache/**/*"]`.
|
|
34
35
|
|
|
35
36
|
### `rails`
|
|
36
37
|
- `test?.databaseImage?` — test DB container image (Postgres only; default `docker.io/postgres:latest`).
|
|
@@ -41,6 +42,7 @@ generated pipeline files.
|
|
|
41
42
|
- `buildVars?: Record<string, string | undefined>` — Bundler / Rails asset-precompile vars (`undefined` inherits from the component's env vars).
|
|
42
43
|
|
|
43
44
|
### `meteor`
|
|
45
|
+
- Yarn-only (meteor's bundler is yarn-based) — a pnpm project cannot use this build type.
|
|
44
46
|
- `installScripts?: boolean` — run `yarn install` inside the source folder in the image (only needed with custom image scripts).
|
|
45
47
|
- `docker?` — meteor built-in or custom. Default `startCommand: "node main.js"`.
|
|
46
48
|
|
|
@@ -68,5 +70,5 @@ defaulted `buildCommand: "yarn build-storybook --quiet -o ./dist"`.
|
|
|
68
70
|
Top-level `builds: Record<string, WorkspaceBuildConfig>`. Only
|
|
69
71
|
`type: "node"` is supported.
|
|
70
72
|
|
|
71
|
-
- Node workspace build: `dir?`, `buildCommand?` (default
|
|
73
|
+
- Node workspace build: `dir?`, `buildCommand?` (default `<pm> build`), `dockerDefaults?: { yarnRebuildEnabled }`, plus shared `lint?` (default `{ command: "<pm> lint" }`), `test?` (default `{ command: "<pm> test" }`), `audit?`, `runnerVariables?`, `artifactsReports?`, `jobImage?`, `jobTags?`, `cache?` (`<pm>` = `yarn`/`pnpm` per detection).
|
|
72
74
|
- A component references it via `build: { from: "<name>", docker?, startCommand?, artifactsPaths?, artifactsExcludePaths?, cache? }` — the per-component overrides layer on top of the shared build.
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
<!-- rendered from the command definitions by
|
|
4
4
|
apps/cli/src/scripts/generateCliSkillReference.ts — do not edit -->
|
|
5
5
|
|
|
6
|
-
All commands run non-interactively as `yarn catladder <command>
|
|
7
|
-
see SKILL.md for how to
|
|
6
|
+
All commands run non-interactively as `yarn catladder <command> ...`
|
|
7
|
+
(`pnpm catladder ...` in pnpm projects); see SKILL.md for how to
|
|
8
|
+
pass inputs.
|
|
8
9
|
|
|
9
10
|
## `catladder cloudsql restore-db`
|
|
10
11
|
|
|
@@ -64,6 +64,11 @@ Key concepts:
|
|
|
64
64
|
- **Pipelines**: `pipelines: { gitlab: true, github: true }` selects
|
|
65
65
|
which CI systems get generated files. Options objects instead of
|
|
66
66
|
`true` allow per-pipeline settings (e.g. `runnerVariables`).
|
|
67
|
+
- **Package manager**: yarn and pnpm are supported and autodetected
|
|
68
|
+
(from the `packageManager` field in package.json or the lockfile;
|
|
69
|
+
yarn is the fallback). `packageManager: "pnpm" | "yarn"` at the top
|
|
70
|
+
level overrides the detection. In pnpm projects, run the CLIs as
|
|
71
|
+
`pnpm catenv` / `pnpm catladder`.
|
|
67
72
|
|
|
68
73
|
## Common tasks
|
|
69
74
|
|
|
@@ -61,7 +61,7 @@ resources with `yarn catladder project setup`; detect drift with
|
|
|
61
61
|
- `type: "pages"` — **required**. Publishes a static site on gitlab pages (not yet supported on the github backend).
|
|
62
62
|
- `script: string[]` — **required**; produces the site.
|
|
63
63
|
- `publishDir?: string` — output directory relative to the repo root, default `"public"`.
|
|
64
|
-
- `
|
|
64
|
+
- `requiresInstall?: boolean` — run the package-manager install (yarn/pnpm) first (`requiresYarnInstall` is a deprecated alias).
|
|
65
65
|
- `jobImage?: GitlabJobImage`; also accepts `cache`.
|
|
66
66
|
- Review envs publish under an `mr-<iid>` path prefix (parallel deployments → MR previews; exposed as `$PAGES_PREFIX`); other envs publish at the root. The environment url is the published pages url.
|
|
67
67
|
- Defaults to `allowFailure: true`.
|
|
@@ -75,7 +75,7 @@ resources with `yarn catladder project setup`; detect drift with
|
|
|
75
75
|
- `type: "custom"` — **required**.
|
|
76
76
|
- `requiresDocker: boolean` — **required**; whether the deploy needs a built Docker image.
|
|
77
77
|
- `script: string[]` — **required**; the deploy script.
|
|
78
|
-
- `
|
|
78
|
+
- `requiresInstall?: boolean` — whether the script needs the package-manager install (`requiresYarnInstall` is a deprecated alias).
|
|
79
79
|
- `stopScript?: string[]` — script to stop/tear down the environment.
|
|
80
80
|
- `jobImage?: GitlabJobImage`.
|
|
81
81
|
- Also accepts `cache` (via `WithCacheConfig`).
|
|
@@ -39,7 +39,9 @@ edit.
|
|
|
39
39
|
## Caching
|
|
40
40
|
|
|
41
41
|
Cache configuration is generated per build type; node builds cache
|
|
42
|
-
`node_modules` and the
|
|
42
|
+
`node_modules` and the package manager's download cache (the `.yarn`
|
|
43
|
+
zip cache, or for pnpm projects a project-local `.pnpm-store`). GitLab
|
|
44
|
+
uses mutable caches with
|
|
43
45
|
fallback keys (review branches fall back to the dev cache); GitHub uses
|
|
44
46
|
immutable lockfile-keyed caches where only the build job writes.
|
|
45
47
|
Caching behavior is changed via the build config in `catladder.ts`,
|
|
@@ -7,7 +7,7 @@ const jobs_1 = require("../../types/jobs");
|
|
|
7
7
|
const utils_1 = require("../../utils");
|
|
8
8
|
const removeUndefined_1 = require("../../utils/removeUndefined");
|
|
9
9
|
const createBuildJobArtifact_1 = require("../artifacts/createBuildJobArtifact");
|
|
10
|
-
const
|
|
10
|
+
const packageManagerInstall_1 = require("../node/packageManagerInstall");
|
|
11
11
|
const constants_1 = require("./constants");
|
|
12
12
|
const writeBuildInfo_1 = require("./writeBuildInfo");
|
|
13
13
|
const writeDotEnv_1 = require("./writeDotEnv");
|
|
@@ -47,7 +47,7 @@ class AppBuildJob extends jobs_1.CatladderJob {
|
|
|
47
47
|
.flatMap((c) => (0, writeDotEnv_1.writeDotEnv)(c))
|
|
48
48
|
: []),
|
|
49
49
|
...(context.type === "component" ? (0, writeBuildInfo_1.writeBuildInfo)(context) : []),
|
|
50
|
-
...(0,
|
|
50
|
+
...(0, packageManagerInstall_1.ensureNodeVersion)(context), // in pure node repos, we might want to have the nvmrc file in top-level
|
|
51
51
|
`cd ${context.build.dir}`,
|
|
52
52
|
...(0, utils_1.ensureArray)(script),
|
|
53
53
|
],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createAppBuildJob.js","sourceRoot":"","sources":["../../../../../../../../packages/pipeline/src/build/base/createAppBuildJob.ts"],"names":[],"mappings":";;;AAAA,yCAAsC;AAMtC,6BAAuC;AAGvC,2CAAgD;AAChD,uCAA0C;AAC1C,iEAA8D;AAC9D,gFAA8E;AAC9E,
|
|
1
|
+
{"version":3,"file":"createAppBuildJob.js","sourceRoot":"","sources":["../../../../../../../../packages/pipeline/src/build/base/createAppBuildJob.ts"],"names":[],"mappings":";;;AAAA,yCAAsC;AAMtC,6BAAuC;AAGvC,2CAAgD;AAChD,uCAA0C;AAC1C,iEAA8D;AAC9D,gFAA8E;AAC9E,yEAAkE;AAClE,2CAGqB;AACrB,qDAAkD;AAClD,+CAGuB;AAEvB,MAAa,WAAY,SAAQ,mBAAY;IAC3C,YACE,OAAoE,EACpE,EACE,MAAM,EACN,SAAS,EACT,eAAe,EACf,KAAK,EACL,GAAG,GAAG,EACgB,EACxB,SAAgC;;QAEhC,KAAK,CAAC;YACJ,IAAI,EAAE,8BAAkB;YACxB,OAAO,EAAE,WAAW;YACpB,KAAK,EAAE,OAAO;YACd,QAAQ,EAAE,CAAC,gBAAgB,CAAC;YAC5B,KAAK,EAAE,IAAA,kBAAc,EAAC,cAAc,CAAC;YACrC,KAAK,EAAE,EAAE;YACT,MAAM,EAAE,KAAK;YACb,SAAS,EAAE;gBACT,GAAG,CAAC,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,EAAE,CAAC;gBACpB,GAAG,CAAC,OAAO,CAAC,IAAI,KAAK,WAAW;oBAC9B,CAAC,CAAC;wBACE,GAAG,OAAO,CAAC,WAAW,CAAC,OAAO;wBAC9B,GAAG,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO;qBACjD;oBACH,CAAC,CAAC,EAAE,CAAC;aACR;YACD,eAAe,EAAE;gBACf,GAAG,2CAA+B;gBAClC,GAAG,CAAC,eAAe,aAAf,eAAe,cAAf,eAAe,GAAI,EAAE,CAAC;gBAC1B,GAAG,CAAC,MAAA,OAAO,CAAC,KAAK,C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ContextWithBuild, WorkspaceContext } from "../types/context";
|
|
1
|
+
import type { ComponentContextWithBuild, PackageManagerType, WorkspaceContext } from "../types/context";
|
|
2
2
|
import type { EnvironmentContext } from "../types/environmentContext";
|
|
3
3
|
import type { CatladderJob } from "../types/jobs";
|
|
4
4
|
import type { BuildConfig, BuildConfigStandaloneType, WorkspaceBuildConfig } from "./types";
|
|
@@ -7,7 +7,7 @@ export * from "./types";
|
|
|
7
7
|
export type BuildTypes = {
|
|
8
8
|
[type in BuildConfigStandaloneType]: {
|
|
9
9
|
jobs: (context: ComponentContextWithBuild) => CatladderJob[] | Promise<CatladderJob[]>;
|
|
10
|
-
defaults: (envContext: EnvironmentContext) => Partial<Extract<BuildConfig, {
|
|
10
|
+
defaults: (envContext: EnvironmentContext, packageManager: PackageManagerType) => Partial<Extract<BuildConfig, {
|
|
11
11
|
type: type;
|
|
12
12
|
}>>;
|
|
13
13
|
};
|
|
@@ -16,7 +16,7 @@ export declare const BUILD_TYPES: BuildTypes;
|
|
|
16
16
|
export type WorkspaceBuildTypes = {
|
|
17
17
|
[type in WorkspaceBuildConfig["type"]]: {
|
|
18
18
|
jobs: (context: WorkspaceContext) => CatladderJob[] | Promise<CatladderJob[]>;
|
|
19
|
-
defaults: () => Partial<Extract<WorkspaceBuildConfig, {
|
|
19
|
+
defaults: (packageManager: PackageManagerType) => Partial<Extract<WorkspaceBuildConfig, {
|
|
20
20
|
type: type;
|
|
21
21
|
}>>;
|
|
22
22
|
};
|
|
@@ -20,27 +20,32 @@ const node_1 = require("./node");
|
|
|
20
20
|
const rails_1 = require("./rails");
|
|
21
21
|
__exportStar(require("./node"), exports);
|
|
22
22
|
__exportStar(require("./types"), exports);
|
|
23
|
+
/**
|
|
24
|
+
* run a package.json script with the project's package manager
|
|
25
|
+
* (`yarn build` / `pnpm build`)
|
|
26
|
+
*/
|
|
27
|
+
const runScript = (packageManager, script) => `${packageManager} ${script}`;
|
|
23
28
|
exports.BUILD_TYPES = {
|
|
24
29
|
node: {
|
|
25
30
|
jobs: node_1.createNodeJobs,
|
|
26
|
-
defaults: () => ({
|
|
27
|
-
buildCommand: "
|
|
28
|
-
startCommand: "
|
|
31
|
+
defaults: (_, pm) => ({
|
|
32
|
+
buildCommand: runScript(pm, "build"),
|
|
33
|
+
startCommand: runScript(pm, "start"),
|
|
29
34
|
artifactsPaths: ["dist", ".next"],
|
|
30
35
|
artifactsExcludePaths: [".next/cache/**/*"],
|
|
31
36
|
}),
|
|
32
37
|
},
|
|
33
38
|
"node-static": {
|
|
34
39
|
jobs: node_1.createNodeJobs,
|
|
35
|
-
defaults: () => ({
|
|
36
|
-
buildCommand: "
|
|
40
|
+
defaults: (_, pm) => ({
|
|
41
|
+
buildCommand: runScript(pm, "build"),
|
|
37
42
|
artifactsPaths: ["dist"],
|
|
38
43
|
}),
|
|
39
44
|
},
|
|
40
45
|
storybook: {
|
|
41
46
|
jobs: node_1.createStorybookJobs,
|
|
42
|
-
defaults: () => ({
|
|
43
|
-
buildCommand: ["
|
|
47
|
+
defaults: (_, pm) => ({
|
|
48
|
+
buildCommand: [runScript(pm, "build-storybook --quiet -o ./dist")],
|
|
44
49
|
artifactsPaths: ["dist"],
|
|
45
50
|
}),
|
|
46
51
|
},
|
|
@@ -70,13 +75,13 @@ exports.BUILD_TYPES = {
|
|
|
70
75
|
exports.WORKSPACE_BUILD_TYPES = {
|
|
71
76
|
node: {
|
|
72
77
|
jobs: node_1.createNodeJobs,
|
|
73
|
-
defaults: () => ({
|
|
74
|
-
buildCommand: "
|
|
78
|
+
defaults: (pm) => ({
|
|
79
|
+
buildCommand: runScript(pm, "build"),
|
|
75
80
|
lint: {
|
|
76
|
-
command: "
|
|
81
|
+
command: runScript(pm, "lint"),
|
|
77
82
|
},
|
|
78
83
|
test: {
|
|
79
|
-
command: "
|
|
84
|
+
command: runScript(pm, "test"),
|
|
80
85
|
},
|
|
81
86
|
}),
|
|
82
87
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/pipeline/src/build/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/pipeline/src/build/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAQA,qCAA4C;AAC5C,iCAA+E;AAC/E,mCAA0C;AAO1C,yCAAuB;AACvB,0CAAwB;AAExB;;;GAGG;AACH,MAAM,SAAS,GAAG,CAAC,cAAkC,EAAE,MAAc,EAAE,EAAE,CACvE,GAAG,cAAc,IAAI,MAAM,EAAE,CAAC;AAcnB,QAAA,WAAW,GAAe;IACrC,IAAI,EAAE;QACJ,IAAI,EAAE,qBAAc;QACpB,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;YACpB,YAAY,EAAE,SAAS,CAAC,EAAE,EAAE,OAAO,CAAC;YACpC,YAAY,EAAE,SAAS,CAAC,EAAE,EAAE,OAAO,CAAC;YACpC,cAAc,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC;YACjC,qBAAqB,EAAE,CAAC,kBAAkB,CAAC;SAC5C,CAAC;KACH;IACD,aAAa,EAAE;QACb,IAAI,EAAE,qBAAc;QACpB,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;YACpB,YAAY,EAAE,SAAS,CAAC,EAAE,EAAE,OAAO,CAAC;YACpC,cAAc,EAAE,CAAC,MAAM,CAAC;SACzB,CAAC;KACH;IACD,SAAS,EAAE;QACT,IAAI,EAAE,0BAAmB;QACzB,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;YACpB,YAAY,EAAE,CAAC,SAAS,CAAC,EAAE,EAAE,mCAAmC,CAAC,CAAC;YAClE,cAAc,EAAE,CAAC,MAAM,CAAC;SACzB,CAAC;KACH;IACD,MAAM,EAAE;QACN,IAAI,EAAE,uBAAgB;QACtB,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC;YACf,YAAY,EAAE,cAAc;YAC5B,cAAc,EAAE,CAAC,MAAM,CAAC;SACzB,CAAC;KACH;IACD,MAAM,EAAE;QACN,IAAI,EAAE,yBAAgB;QACtB,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC;YACf,cAAc,EAAE,CAAC,MAAM,CAAC;SACzB,CAAC;KACH;IACD,KAAK,EAAE;QACL,IAAI,EAAE,uBAAe;QACrB,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC;YACf,UAAU,EAAE;gBACV,KAAK,EAAE,mBAAmB;gBAC1B,WAAW,EAAE,QAAQ;aACtB;SACF,CAAC;KACH;CACF,CAAC;AAaW,QAAA,qBAAqB,GAAwB;IACxD,IAAI,EAAE;QACJ,IAAI,EAAE,qBAAc;QACpB,QAAQ,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;YACjB,YAAY,EAAE,SAAS,CAAC,EAAE,EAAE,OAAO,CAAC;YACpC,IAAI,EAAE;gBACJ,OAAO,EAAE,SAAS,CAAC,EAAE,EAAE,MAAM,CAAC;aAC/B;YACD,IAAI,EAAE;gBACJ,OAAO,EAAE,SAAS,CAAC,EAAE,EAAE,MAAM,CAAC;aAC/B;SACF,CAAC;KACH;CACF,CAAC"}
|
|
@@ -6,7 +6,7 @@ const base_1 = require("../base");
|
|
|
6
6
|
const createBuildJobDefinition_1 = require("../base/createBuildJobDefinition");
|
|
7
7
|
const docker_1 = require("../docker");
|
|
8
8
|
const cache_1 = require("./cache");
|
|
9
|
-
const
|
|
9
|
+
const packageManagerInstall_1 = require("./packageManagerInstall");
|
|
10
10
|
const createNodeBuildJobs = async (context) => {
|
|
11
11
|
if (context.type === "workspace") {
|
|
12
12
|
return (0, base_1.createWorkspaceBuildJobs)(context, {
|
|
@@ -23,18 +23,17 @@ const createNodeBuildJobs = async (context) => {
|
|
|
23
23
|
exports.createNodeBuildJobs = createNodeBuildJobs;
|
|
24
24
|
const createNodeBuildJobDefinition = async (context) => {
|
|
25
25
|
const buildConfig = context.build.config;
|
|
26
|
-
const [
|
|
27
|
-
(0,
|
|
26
|
+
const [packageManagerInstall, nodeCache] = await Promise.all([
|
|
27
|
+
(0, packageManagerInstall_1.getPackageManagerInstall)(context),
|
|
28
28
|
(0, cache_1.getNodeCache)(context),
|
|
29
29
|
]);
|
|
30
30
|
return (0, createBuildJobDefinition_1.createBuildJobDefinition)(context, buildConfig, {
|
|
31
|
-
prescript:
|
|
31
|
+
prescript: packageManagerInstall,
|
|
32
32
|
cache: nodeCache,
|
|
33
33
|
});
|
|
34
34
|
};
|
|
35
35
|
exports.createNodeBuildJobDefinition = createNodeBuildJobDefinition;
|
|
36
36
|
const createNodeDockerJobDefinition = async (context) => {
|
|
37
|
-
var _a;
|
|
38
37
|
// get the default docker built-in type based on the build type
|
|
39
38
|
const dockerDefaultBuiltIn = context.build.buildType === "node-static" ||
|
|
40
39
|
context.build.buildType === "storybook"
|
|
@@ -42,16 +41,58 @@ const createNodeDockerJobDefinition = async (context) => {
|
|
|
42
41
|
: "node";
|
|
43
42
|
const [yarnCache, dockerAppCopyAndBuildScript, packageManagerInfo] = await Promise.all([
|
|
44
43
|
(0, cache_1.getYarnCache)(context, "pull"),
|
|
45
|
-
(0,
|
|
44
|
+
(0, packageManagerInstall_1.getDockerAppCopyAndBuildScript)(context),
|
|
46
45
|
context.packageManagerInfo,
|
|
47
46
|
]);
|
|
47
|
+
// the pnpm store (pulled via the cache above) is copied into the
|
|
48
|
+
// image so the prod install works offline — like the yarn zip cache,
|
|
49
|
+
// which travels inside the copied `.yarn` config folder
|
|
50
|
+
const copyPnpmStore = packageManagerInfo.type === "pnpm" &&
|
|
51
|
+
packageManagerInfo.componentIsInWorkspace;
|
|
52
|
+
// pnpm copies every workspace manifest into the image — as individual
|
|
53
|
+
// COPY instructions that many layers exceed docker's depth limit, so
|
|
54
|
+
// the job tars them up and a single ADD extracts them
|
|
55
|
+
const isPnpm = packageManagerInfo.type === "pnpm";
|
|
56
|
+
const WORKSPACE_FILES_TAR = ".catladder-workspace-files.tar";
|
|
48
57
|
return {
|
|
49
|
-
script:
|
|
58
|
+
script: [
|
|
59
|
+
// the COPY source must exist even when the cache was cold
|
|
60
|
+
...(copyPnpmStore ? ["mkdir -p .pnpm-store"] : []),
|
|
61
|
+
...(isPnpm
|
|
62
|
+
? [
|
|
63
|
+
`tar -cf ${WORKSPACE_FILES_TAR} ${packageManagerInfo.pathsToCopyInDocker.join(" ")}`,
|
|
64
|
+
]
|
|
65
|
+
: []),
|
|
66
|
+
...(0, docker_1.getDockerBuildScriptWithBuiltInDockerFile)(context, dockerDefaultBuiltIn),
|
|
67
|
+
],
|
|
50
68
|
cache: [...yarnCache],
|
|
51
69
|
variables: {
|
|
52
70
|
// only required for non static
|
|
53
71
|
DOCKER_COPY_AND_INSTALL_APP: dockerAppCopyAndBuildScript,
|
|
54
|
-
DOCKER_COPY_WORKSPACE_FILES:
|
|
72
|
+
DOCKER_COPY_WORKSPACE_FILES: isPnpm
|
|
73
|
+
? [
|
|
74
|
+
`ADD ${WORKSPACE_FILES_TAR} /app/`,
|
|
75
|
+
// ADD does not apply --chown to extracted tars, and parent
|
|
76
|
+
// dirs of the entries come out root-owned — fix ownership
|
|
77
|
+
// while the stage still runs as root (store not copied yet,
|
|
78
|
+
// so this only touches the small manifest tree). Custom
|
|
79
|
+
// base images without a node user run as root and don't
|
|
80
|
+
// need it, hence the fallback
|
|
81
|
+
`RUN chown -R node:node /app || true`,
|
|
82
|
+
...(copyPnpmStore
|
|
83
|
+
? [`COPY --chown=node:node .pnpm-store /app/.pnpm-store`]
|
|
84
|
+
: []),
|
|
85
|
+
].join("\n")
|
|
86
|
+
: packageManagerInfo.pathsToCopyInDocker
|
|
87
|
+
.map((dir) => `COPY --chown=node:node ${dir} /app/${dir}`)
|
|
88
|
+
.join("\n"),
|
|
89
|
+
// pnpm is not preinstalled in the node base images; installed as
|
|
90
|
+
// root before the image switches to the node user
|
|
91
|
+
...(isPnpm
|
|
92
|
+
? {
|
|
93
|
+
DOCKER_SETUP_PACKAGE_MANAGER: `RUN npm install -g pnpm@${packageManagerInfo.version}`,
|
|
94
|
+
}
|
|
95
|
+
: {}),
|
|
55
96
|
},
|
|
56
97
|
};
|
|
57
98
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildJob.js","sourceRoot":"","sources":["../../../../../../../../packages/pipeline/src/build/node/buildJob.ts"],"names":[],"mappings":";;;AAKA,iDAG6B;AAM7B,kCAA6E;AAC7E,+EAA4E;AAC5E,sCAAsE;AAEtE,mCAAqD;AACrD,
|
|
1
|
+
{"version":3,"file":"buildJob.js","sourceRoot":"","sources":["../../../../../../../../packages/pipeline/src/build/node/buildJob.ts"],"names":[],"mappings":";;;AAKA,iDAG6B;AAM7B,kCAA6E;AAC7E,+EAA4E;AAC5E,sCAAsE;AAEtE,mCAAqD;AACrD,mEAGiC;AAE1B,MAAM,mBAAmB,GAAG,KAAK,EACtC,OAAqD,EAC5B,EAAE;IAC3B,IAAI,OAAO,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;QACjC,OAAO,IAAA,+BAAwB,EAAC,OAAO,EAAE;YACvC,QAAQ,EAAE,MAAM,IAAA,oCAA4B,EAAC,OAAO,CAAC;SACtD,CAAC,CAAC;IACL,CAAC;IACD,OAAO,IAAA,+BAAwB,EAAC,OAAO,EAAE;QACvC,QAAQ,EAAE,IAAA,2CAAiC,EAAC,OAAO,CAAC;YAClD,CAAC,CAAC,MAAM,IAAA,oCAA4B,EAAC,OAAO,CAAC;YAC7C,CAAC,CAAC,SAAS;QAEb,WAAW,EAAE,MAAM,IAAA,qCAA6B,EAAC,OAAO,CAAC;KAC1D,CAAC,CAAC;AACL,CAAC,CAAC;AAfW,QAAA,mBAAmB,uBAe9B;AAEK,MAAM,4BAA4B,GAAG,KAAK,EAC/C,OAAoE,EACxB,EAAE;IAC9C,MAAM,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC,MAA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C,EAAE,CAAC;YAClD,GAAG,CAAC,MAAM;gBACR,CAAC,CAAC;oBACE,WAAW,mBAAmB,IAAI,kBAAkB,CAAC,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;iBACrF;gBACH,CAAC,CAAC,EAAE,CAAC;YACP,GAAG,IAAA,kDAAyC,EAC1C,OAAO,EACP,oBAAoB,CACrB;SACF;QACD,KAAK,EAAE,CAAC,GAAG,SAAS,CAAC;QACrB,SAAS,EAAE;YACT,+BAA+B;YAC/B,2BAA2B,EAAE,2BAA2B;YACxD,2BAA2B,EAAE,MAAM;gBACjC,CAAC,CAAC;oBACE,OAAO,mBAAmB,QAAQ;oBAClC,2DAA2D;oBAC3D,0DAA0D;oBAC1D,4DAA4D;oBAC5D,wDAAwD;oBACxD,wDAAwD;oBACxD,8BAA8B;oBAC9B,qCAAqC;oBACrC,GAAG,CAAC,aAAa;wBACf,CAAC,CAAC,CAAC,qDAAqD,CAAC;wBACzD,CAAC,CAAC,EAAE,CAAC;iBACR,CAAC,IAAI,CAAC,IAAI,CAAC;gBACd,CAAC,CAAC,kBAAkB,CAAC,mBAAmB;qBACnC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,0BAA0B,GAAG,SAAS,GAAG,EAAE,CAAC;qBACzD,IAAI,CAAC,IAAI,CAAC;YACjB,iEAAiE;YACjE,kDAAkD;YAClD,GAAG,CAAC,MAAM;gBACR,CAAC,CAAC;oBACE,4BAA4B,EAAE,2BAA2B,kBAAkB,CAAC,OAAO,EAAE;iBACtF;gBACH,CAAC,CAAC,EAAE,CAAC;SACR;KACF,CAAC;AACJ,CAAC,CAAC;AA1EW,QAAA,6BAA6B,iCA0ExC"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { Context } from "../../types/context";
|
|
2
2
|
import type { CacheConfig } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* the package manager's download cache: yarn's `.yarn` zip cache, or
|
|
5
|
+
* pnpm's content-addressable store (which catladder points at a
|
|
6
|
+
* project-local `.pnpm-store`, see the install script)
|
|
7
|
+
*/
|
|
3
8
|
export declare const getYarnCache: (context: Context, policy?: string) => Promise<CacheConfig[]>;
|
|
4
9
|
export declare const getNodeModulesCache: (context: Context, policy?: string) => Promise<CacheConfig[]>;
|
|
5
10
|
export declare const getNodeCache: (context: Context, policy?: string) => Promise<CacheConfig[]>;
|
|
@@ -4,12 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getNodeCache = exports.getNodeModulesCache = exports.getYarnCache = void 0;
|
|
7
|
+
const lodash_es_1 = require("lodash-es");
|
|
7
8
|
const path_1 = require("path");
|
|
8
9
|
const slugify_1 = __importDefault(require("slugify"));
|
|
9
10
|
/**
|
|
10
|
-
* stable reference between the two node caches: the
|
|
11
|
-
* declares itself redundant when the
|
|
12
|
-
* exact-lockfile hit (github skips the
|
|
11
|
+
* stable reference between the two node caches: the package-manager
|
|
12
|
+
* (yarn zip / pnpm store) cache declares itself redundant when the
|
|
13
|
+
* node_modules cache scored an exact-lockfile hit (github skips the
|
|
14
|
+
* ~0.6GB download on warm runs)
|
|
13
15
|
*/
|
|
14
16
|
const NODE_MODULES_CACHE_ID = "node-modules";
|
|
15
17
|
/**
|
|
@@ -36,23 +38,37 @@ const getCacheBaseDir = async (context) => {
|
|
|
36
38
|
? ((_a = context.build.workspaceBuildConfig.dir) !== null && _a !== void 0 ? _a : ".")
|
|
37
39
|
: ".";
|
|
38
40
|
};
|
|
41
|
+
/**
|
|
42
|
+
* the package manager's download cache: yarn's `.yarn` zip cache, or
|
|
43
|
+
* pnpm's content-addressable store (which catladder points at a
|
|
44
|
+
* project-local `.pnpm-store`, see the install script)
|
|
45
|
+
*/
|
|
39
46
|
const getYarnCache = async (context, policy = "pull-push") => {
|
|
47
|
+
const packageManagerInfo = await context.packageManagerInfo;
|
|
48
|
+
const isPnpm = packageManagerInfo.type === "pnpm";
|
|
40
49
|
const baseDir = await getCacheBaseDir(context);
|
|
50
|
+
// pnpm keeps its store in a format-versioned subdir (v10, v11, ...)
|
|
51
|
+
// and never cleans old ones up — scope the cache slot by major so a
|
|
52
|
+
// pnpm upgrade starts a fresh slot instead of dragging the dead old
|
|
53
|
+
// store tree along in every cache transfer (formats change only on
|
|
54
|
+
// majors)
|
|
55
|
+
const pnpmStoreKey = `pnpm-v${packageManagerInfo.version.split(".")[0]}`;
|
|
41
56
|
return [
|
|
42
57
|
{
|
|
43
58
|
scope: "buildDir",
|
|
44
59
|
pathMode: "relative",
|
|
45
60
|
buildDir: baseDir,
|
|
46
|
-
key: "yarn",
|
|
61
|
+
key: isPnpm ? pnpmStoreKey : "yarn",
|
|
47
62
|
policy,
|
|
48
|
-
paths: [".yarn"],
|
|
63
|
+
paths: [isPnpm ? ".pnpm-store" : ".yarn"],
|
|
49
64
|
// content-key for immutable-cache backends (github); the lockfile
|
|
50
65
|
// decides whether the cached content could have changed
|
|
51
|
-
keyFiles: ["yarn.lock"],
|
|
52
|
-
// the
|
|
53
|
-
//
|
|
54
|
-
// same lockfile, install verifies
|
|
55
|
-
//
|
|
66
|
+
keyFiles: [isPnpm ? "pnpm-lock.yaml" : "yarn.lock"],
|
|
67
|
+
// the package manager's download cache (~hundreds of MB) is only
|
|
68
|
+
// read when packages have to be (re)installed. When the
|
|
69
|
+
// node_modules cache hit for the same lockfile, install verifies
|
|
70
|
+
// its state file and never touches the store — so github skips
|
|
71
|
+
// downloading this cache entirely
|
|
56
72
|
redundantOnExactHitOf: NODE_MODULES_CACHE_ID,
|
|
57
73
|
},
|
|
58
74
|
];
|
|
@@ -61,27 +77,50 @@ exports.getYarnCache = getYarnCache;
|
|
|
61
77
|
const getNodeModulesCache = async (context, policy = "pull-push") => {
|
|
62
78
|
const packageManagerInfo = await context.packageManagerInfo;
|
|
63
79
|
const baseDir = await getCacheBaseDir(context);
|
|
64
|
-
const {
|
|
65
|
-
|
|
80
|
+
const { workspaces } = packageManagerInfo;
|
|
81
|
+
const isPnpm = packageManagerInfo.type === "pnpm";
|
|
82
|
+
const lockFileName = isPnpm ? "pnpm-lock.yaml" : "yarn.lock";
|
|
83
|
+
// yarn berry tracks install state in .yarn/install-state.gz (pnpm's
|
|
84
|
+
// equivalent lives inside node_modules and is covered by the paths)
|
|
85
|
+
const hasInstallState = packageManagerInfo.type === "yarn" && !packageManagerInfo.isClassic;
|
|
86
|
+
// We intentionally do not use the contents of the lockfile as a cache key, as install should always guarantee that the files are updated, but it can still use part of the cache if not all packages are up-to-date.
|
|
66
87
|
// It would slow down all pipelines whenever one adds a new dependency as it will need to download all node_modules again.
|
|
67
88
|
return [
|
|
68
89
|
{
|
|
69
90
|
scope: "global",
|
|
70
91
|
pathMode: "absolute",
|
|
71
92
|
// we use the dirname, not the component name, because in certain cases we have two apps in the same directory and want to share the cache, e.g. when having storybook in the same package.json
|
|
72
|
-
|
|
93
|
+
//
|
|
94
|
+
// pnpm gets its own, lockfile-keyed cache: node_modules layouts
|
|
95
|
+
// are not compatible between package managers (a migrating
|
|
96
|
+
// project must not inherit the yarn slot), and unlike yarn, a
|
|
97
|
+
// pnpm install on top of a node_modules from a different lockfile
|
|
98
|
+
// leaves orphaned .pnpm dirs behind that break type identity —
|
|
99
|
+
// so the slot changes whenever the lockfile changes
|
|
100
|
+
key: isPnpm
|
|
101
|
+
? {
|
|
102
|
+
prefix: "pnpm-" + (0, slugify_1.default)(baseDir) + "-node-modules",
|
|
103
|
+
files: [(0, path_1.join)(baseDir, "pnpm-lock.yaml")],
|
|
104
|
+
}
|
|
105
|
+
: (0, slugify_1.default)(baseDir) + "-node-modules",
|
|
73
106
|
// content-key for immutable-cache backends (github); the lockfile
|
|
74
107
|
// decides whether the cached content could have changed (absolute
|
|
75
108
|
// pathMode: resolve the lockfile explicitly)
|
|
76
|
-
keyFiles: [(0, path_1.join)(baseDir,
|
|
77
|
-
// referenced by the
|
|
78
|
-
//
|
|
109
|
+
keyFiles: [(0, path_1.join)(baseDir, lockFileName)],
|
|
110
|
+
// referenced by the package-manager cache: an exact hit here makes
|
|
111
|
+
// it unnecessary (see redundantOnExactHitOf on getYarnCache)
|
|
79
112
|
cacheId: NODE_MODULES_CACHE_ID,
|
|
80
113
|
policy,
|
|
81
|
-
paths: [
|
|
114
|
+
paths: (0, lodash_es_1.uniq)([
|
|
82
115
|
(0, path_1.join)(baseDir, "node_modules"),
|
|
83
|
-
|
|
84
|
-
|
|
116
|
+
// pnpm's per-package node_modules are symlink farms worth
|
|
117
|
+
// keeping warm (yarn hoists into the root, so root-only
|
|
118
|
+
// matches its historical behavior)
|
|
119
|
+
...(isPnpm
|
|
120
|
+
? workspaces.map((w) => (0, path_1.join)(w.location, "node_modules"))
|
|
121
|
+
: []),
|
|
122
|
+
...(hasInstallState ? [(0, path_1.join)(baseDir, ".yarn/install-state.gz")] : []),
|
|
123
|
+
]),
|
|
85
124
|
},
|
|
86
125
|
];
|
|
87
126
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../../../../../../../../packages/pipeline/src/build/node/cache.ts"],"names":[],"mappings":";;;;;;AAAA,+BAA4B;AAC5B,sDAA8B;AAK9B
|
|
1
|
+
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../../../../../../../../packages/pipeline/src/build/node/cache.ts"],"names":[],"mappings":";;;;;;AAAA,yCAAiC;AACjC,+BAA4B;AAC5B,sDAA8B;AAK9B;;;;;GAKG;AACH,MAAM,qBAAqB,GAAG,cAAc,CAAC;AAE7C;;;;;;;;GAQG;AACH,MAAM,eAAe,GAAG,KAAK,EAAE,OAAgB,EAAmB,EAAE;;IAClE,MAAM,kBAAkB,GAAG,MAAM,OAAO,CAAC,kBAAkB,CAAC;IAC5D,MAAM,sBAAsB,GAC1B,OAAO,CAAC,IAAI,KAAK,WAAW;QAC5B,wBAAwB,IAAI,kBAAkB;QAC9C,kBAAkB,CAAC,sBAAsB,CAA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AA6D;YAC7D,OAAO,EAAE,qBAAqB;YAC9B,MAAM;YACN,KAAK,EAAE,IAAA,gBAAI,EAAC;gBACV,IAAA,WAAI,EAAC,OAAO,EAAE,cAAc,CAAC;gBAC7B,0DAA0D;gBAC1D,wDAAwD;gBACxD,mCAAmC;gBACnC,GAAG,CAAC,MAAM;oBACR,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,WAAI,EAAC,CAAC,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;oBACzD,CAAC,CAAC,EAAE,CAAC;gBACP,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,IAAA,WAAI,EAAC,OAAO,EAAE,wBAAwB,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;aACtE,CAAC;SACH;KACF,CAAC;AACJ,CAAC,CAAC;AAxDW,QAAA,mBAAmB,uBAwD9B;AACK,MAAM,YAAY,GAAG,KAAK,EAC/B,OAAgB,EAChB,MAAM,GAAG,WAAW,EACI,EAAE;IAC1B,OAAO;QACL,GAAG,CAAC,MAAM,IAAA,oBAAY,EAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACxC,GAAG,CAAC,MAAM,IAAA,2BAAmB,EAAC,OAAO,EAAE,MAAM,CAAC,CAAC;KAChD,CAAC;AACJ,CAAC,CAAC;AARW,QAAA,YAAY,gBAQvB"}
|
|
@@ -7,7 +7,7 @@ const base_1 = require("../base");
|
|
|
7
7
|
const docker_1 = require("../docker");
|
|
8
8
|
const types_1 = require("../types");
|
|
9
9
|
const cache_1 = require("./cache");
|
|
10
|
-
const
|
|
10
|
+
const packageManagerInstall_1 = require("./packageManagerInstall");
|
|
11
11
|
const getMeteorCache = (context) => [
|
|
12
12
|
{
|
|
13
13
|
key: "meteor-build-cache",
|
|
@@ -22,6 +22,11 @@ const getMeteorCache = (context) => [
|
|
|
22
22
|
];
|
|
23
23
|
const getMeteorDockerInstallScripts = async (context) => {
|
|
24
24
|
const packageManagerInfo = await context.packageManagerInfo;
|
|
25
|
+
if (packageManagerInfo.type === "pnpm") {
|
|
26
|
+
// not a meteor limitation — catladder's meteor docker install path
|
|
27
|
+
// is only implemented for yarn so far
|
|
28
|
+
throw new Error("the meteor build type is only implemented for yarn in catladder");
|
|
29
|
+
}
|
|
25
30
|
if (packageManagerInfo.isClassic) {
|
|
26
31
|
return new bash_1.BashExpression(`
|
|
27
32
|
COPY $APP_DIR/package.json $APP_DIR/yarn.lock ./
|
|
@@ -48,8 +53,8 @@ const createMeteorBuildJobs = async (context) => {
|
|
|
48
53
|
if (!(0, types_1.isOfBuildType)(buildConfig, "meteor")) {
|
|
49
54
|
throw new Error("deploy config is not meteor");
|
|
50
55
|
}
|
|
51
|
-
const [
|
|
52
|
-
(0,
|
|
56
|
+
const [packageManagerInstall, nodeCache, meteorInstallScripts] = await Promise.all([
|
|
57
|
+
(0, packageManagerInstall_1.getPackageManagerInstall)(context),
|
|
53
58
|
(0, cache_1.getNodeCache)(context),
|
|
54
59
|
buildConfig.installScripts
|
|
55
60
|
? getMeteorDockerInstallScripts(context)
|
|
@@ -64,7 +69,7 @@ const createMeteorBuildJobs = async (context) => {
|
|
|
64
69
|
METEOR_DISABLE_OPTIMISTIC_CACHING: "1", // see https://forums.meteor.com/t/veeery-long-building-time-inside-docker-container/58673/17?u=macrozone
|
|
65
70
|
},
|
|
66
71
|
script: [
|
|
67
|
-
...
|
|
72
|
+
...packageManagerInstall,
|
|
68
73
|
'TOOL_NODE_FLAGS="--max_old_space_size=3584 --min_semi_space_size=8 --max_semi_space_size=256 --optimize_for_size" meteor build ./dist --architecture os.linux.x86_64 --allow-superuser --server-only --directory',
|
|
69
74
|
"cp ./__build_info.json ./dist/bundle/programs/server",
|
|
70
75
|
],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meteor.js","sourceRoot":"","sources":["../../../../../../../../packages/pipeline/src/build/node/meteor.ts"],"names":[],"mappings":";;;AAAA,0CAAiD;AACjD,yCAA8C;AAQ9C,kCAAmD;AACnD,sCAAsE;AAEtE,oCAAyC;AACzC,mCAAuC;AACvC,
|
|
1
|
+
{"version":3,"file":"meteor.js","sourceRoot":"","sources":["../../../../../../../../packages/pipeline/src/build/node/meteor.ts"],"names":[],"mappings":";;;AAAA,0CAAiD;AACjD,yCAA8C;AAQ9C,kCAAmD;AACnD,sCAAsE;AAEtE,oCAAyC;AACzC,mCAAuC;AACvC,mEAAmE;AAEnE,MAAM,cAAc,GAAG,CAAC,OAAyB,EAAiB,EAAE,CAAC;IACnE;QACE,GAAG,EAAE,oBAAoB;QACzB,MAAM,EAAE,WAAW;QACnB,KAAK,EAAE;YACL,0CAA0C;YAC1C,4BAA4B;YAC5B,wBAAwB;YACxB,qCAAqC;SACtC;KACF;CACF,CAAC;AACF,MAAM,6BAA6B,GAAG,KAAK,EACzC,OAAkC,EACT,EAAE;IAC3B,MAAM,kBAAkB,GAAG,MAAM,OAAO,CAAC,kBAAkB,CAAC;IAC5D,IAAI,kBAAkB,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QACvC,mEAAmE;QACnE,sCAAsC;QACtC,MAAM,IAAI,KAAK,CACb,iEAAiE,CAClE,CAAC;IACJ,CAAC;IACD,IAAI,kBAAkB,CAAC,SAAS,EAAE,CAAC;QACjC,OAAO,IAAI,qBAAc,CACvB;;;;;;OAMC,CAAC,IAAI,EAAE,CACT,CAAC;IACJ,CAAC;IAED,wFAAwF;IACxF,MAAM,6BAA6B,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAC1D,kBAAkB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CACzC,CAAC;IACF,MAAM,6BAA6B,GAAG,6BAA6B;QACjE,CAAC,CAAC,wCAAwC;QAC1C,CAAC,CAAC,EAAE,CAAC;IAEP,OAAO,IAAI,qBAAc,CACvB;;;EAGF,6BAA6B;;KAE1B,CAAC,IAAI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