@o3r/pipeline 11.5.0-prerelease.32 → 11.5.0-prerelease.34

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@o3r/pipeline",
3
- "version": "11.5.0-prerelease.32",
3
+ "version": "11.5.0-prerelease.34",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -40,8 +40,8 @@
40
40
  },
41
41
  "peerDependencies": {
42
42
  "@angular-devkit/schematics": "~18.2.0",
43
- "@o3r/schematics": "^11.5.0-prerelease.32",
44
- "@o3r/telemetry": "^11.5.0-prerelease.32",
43
+ "@o3r/schematics": "^11.5.0-prerelease.34",
44
+ "@o3r/telemetry": "^11.5.0-prerelease.34",
45
45
  "type-fest": "^4.10.2"
46
46
  },
47
47
  "peerDependenciesMeta": {
@@ -67,11 +67,11 @@
67
67
  "@nx/eslint-plugin": "~19.5.0",
68
68
  "@nx/jest": "~19.5.0",
69
69
  "@nx/js": "~19.5.0",
70
- "@o3r/build-helpers": "^11.5.0-prerelease.32",
71
- "@o3r/eslint-plugin": "^11.5.0-prerelease.32",
72
- "@o3r/schematics": "^11.5.0-prerelease.32",
73
- "@o3r/telemetry": "^11.5.0-prerelease.32",
74
- "@o3r/test-helpers": "^11.5.0-prerelease.32",
70
+ "@o3r/build-helpers": "^11.5.0-prerelease.34",
71
+ "@o3r/eslint-plugin": "^11.5.0-prerelease.34",
72
+ "@o3r/schematics": "^11.5.0-prerelease.34",
73
+ "@o3r/telemetry": "^11.5.0-prerelease.34",
74
+ "@o3r/test-helpers": "^11.5.0-prerelease.34",
75
75
  "@schematics/angular": "~18.2.0",
76
76
  "@stylistic/eslint-plugin-ts": "~2.4.0",
77
77
  "@types/jest": "~29.5.2",
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/ng-add/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgD,IAAI,EAAiB,MAAM,4BAA4B,CAAC;AAC/G,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AA6EtD;;;GAGG;AACH,eAAO,MAAM,KAAK,YAAa,qBAAqB,KAAG,IAQtD,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/ng-add/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgD,IAAI,EAA4B,MAAM,4BAA4B,CAAC;AAK1H,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAqFtD;;;GAGG;AACH,eAAO,MAAM,KAAK,YAAa,qBAAqB,KAAG,IAQtD,CAAC"}
@@ -3,8 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ngAdd = void 0;
4
4
  const schematics_1 = require("@angular-devkit/schematics");
5
5
  const js_yaml_1 = require("js-yaml");
6
- const path = require("node:path");
7
6
  const fs = require("node:fs");
7
+ const path = require("node:path");
8
+ /**
9
+ * Determines if the Yarn version is 2 or higher based on the contents of the .yarnrc.yml file.
10
+ * @param tree tree
11
+ */
12
+ function isYarn2(tree) {
13
+ const yarnrcPath = '/.yarnrc.yml';
14
+ if (tree.exists(yarnrcPath)) {
15
+ const { yarnPath } = ((0, js_yaml_1.load)(tree.readText(yarnrcPath)) || {});
16
+ return !yarnPath || !/yarn-1\./.test(yarnPath);
17
+ }
18
+ return false;
19
+ }
8
20
  /**
9
21
  * Add an Otter CI pipeline to an Angular Project
10
22
  * @param options
@@ -26,12 +38,14 @@ function ngAddFn(options) {
26
38
  }
27
39
  context.logger.info(`Setting up pipeline for package manager: "${packageManager}" `);
28
40
  const setupCommand = packageManager === 'yarn' ? 'yarn install --immutable' : 'npm ci';
41
+ const yarn2 = packageManager === 'yarn' && isYarn2(tree);
29
42
  const baseTemplateSource = (0, schematics_1.apply)((0, schematics_1.url)(`./templates/${options.toolchain}`), [
30
43
  (0, schematics_1.template)({
31
44
  ...options,
32
45
  packageManager,
33
46
  setupCommand,
34
47
  actionVersionString,
48
+ yarn2,
35
49
  dot: '.'
36
50
  }),
37
51
  (0, schematics_1.move)(tree.root.path)
@@ -40,18 +54,14 @@ function ngAddFn(options) {
40
54
  if (!options.npmRegistry) {
41
55
  return tree;
42
56
  }
43
- if (packageManager === 'yarn') {
57
+ if (yarn2) {
44
58
  const yarnrcPath = '/.yarnrc.yml';
45
- if (!tree.exists(yarnrcPath)) {
46
- tree.create(yarnrcPath, (0, js_yaml_1.dump)({ 'npmRegistryServer': options.npmRegistry }, { indent: 2 }));
47
- }
48
- else {
49
- const yarnrcContent = (0, js_yaml_1.load)(tree.readText(yarnrcPath));
50
- yarnrcContent.npmRegistryServer = options.npmRegistry;
51
- tree.overwrite(yarnrcPath, (0, js_yaml_1.dump)(yarnrcContent, { indent: 2 }));
52
- }
59
+ const yarnrcContent = (0, js_yaml_1.load)(tree.readText(yarnrcPath));
60
+ yarnrcContent.npmRegistryServer = options.npmRegistry;
61
+ tree.overwrite(yarnrcPath, (0, js_yaml_1.dump)(yarnrcContent, { indent: 2 }));
53
62
  }
54
- else if (packageManager === 'npm') {
63
+ else {
64
+ // both npm and yarn 1 use .npmrc for the registry
55
65
  const npmrcPath = '/.npmrc';
56
66
  if (!tree.exists(npmrcPath)) {
57
67
  tree.create(npmrcPath, `registry=${options.npmRegistry}`);
@@ -6,16 +6,30 @@ runs:
6
6
  steps:
7
7
  - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
8
8
  with:
9
- node-version: 20
10
- cache: <%= packageManager %>
9
+ node-version: 20<% if (packageManager !== 'yarn') { %>
10
+ cache: <%= packageManager %><% } %>
11
11
  - name: Enable Corepack
12
12
  shell: bash
13
- run: corepack enable
14
- - name: Install
15
- <% if (npmRegistry) { %>
13
+ run: corepack enable<% if (packageManager === 'yarn') { %>
14
+ - name: Get yarn cache directory path
15
+ shell: bash
16
+ id: yarn-cache-dir-path
17
+ run: echo "dir=$(<% if (yarn2) { %>yarn config get cacheFolder<% } else { %>yarn cache dir<% } %>)" >> $GITHUB_OUTPUT
18
+ - name: Cache dependencies
19
+ uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
20
+ with:
21
+ path: |
22
+ ${{ steps.yarn-cache-dir-path.outputs.dir }}
23
+ <% if (yarn2) { %>.yarn/unplugged
24
+ .pnp.cjs
25
+ .pnp.loader.mjs<% } %>
26
+ key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
27
+ restore-keys: |
28
+ ${{ runner.os }}-yarn
29
+ ${{ runner.os }}<% } %>
30
+ - name: Install<% if (npmRegistry) { %>
16
31
  env:
17
32
  COREPACK_NPM_REGISTRY: <%= npmRegistry %>
18
- COREPACK_INTEGRITY_KEYS: ""
19
- <% } %>
33
+ COREPACK_INTEGRITY_KEYS: ""<% } %>
20
34
  shell: bash
21
35
  run: <%= setupCommand %>