Skip to content

Commit 4c6d5fc

Browse files
committed
feat(it-tests): test schematics with yarn 1
1 parent 79d3a02 commit 4c6d5fc

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

.github/workflows/it-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
fail-fast: false
5252
matrix:
5353
os: [ubuntu-latest, windows-latest]
54-
packageManager: [yarn, npm]
54+
packageManager: [yarn, npm, yarn1]
5555
testEnvironment: [o3r-project-with-app]
5656
runs-on: ${{ matrix.os }}
5757
env:

packages/@o3r/create/src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,9 @@ const addOtterFramework = (relativeDirectory = '.', projectPackageManager = 'npm
191191
const runner = process.platform === 'win32' ? `${projectPackageManager}.cmd` : projectPackageManager;
192192
const options = schematicsCliOptions
193193
.flat();
194-
195-
exitProcessIfErrorInSpawnSync(3, spawnSync(runner, ['exec', 'ng', 'add', `@o3r/core@~${version}`, ...(projectPackageManager === 'npm' ? ['--'] : []), ...options], {
194+
console.log(options);
195+
console.log(projectPackageManager);
196+
exitProcessIfErrorInSpawnSync(3, spawnSync(runner, ['exec', 'ng', 'add', `@o3r/core@~${version}`, ...(projectPackageManager === 'npm' ? ['--'] : ['--']), ...options], {
196197
stdio: 'inherit',
197198
cwd
198199
}));

packages/@o3r/test-helpers/src/prepare-test-env.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statS
33
import * as path from 'node:path';
44
import type { PackageJson } from 'type-fest';
55
import { createTestEnvironmentBlank } from './test-environments/create-test-environment-blank';
6-
import { createWithLock, getPackageManager, type Logger, packageManagerInstall, setPackagerManagerConfig, setupGit } from './utilities/index';
6+
import { createWithLock, getPackageManager, isYarn1, type Logger, packageManagerInstall, setPackagerManagerConfig, setupGit, YARN_1_LATEST_VERSION } from './utilities/index';
77
import { createTestEnvironmentOtterProjectWithApp } from './test-environments/create-test-environment-otter-project';
88
import { O3rCliError } from '@o3r/schematics';
99

@@ -15,8 +15,7 @@ export type PrepareTestEnvType = 'blank' | 'o3r-project-with-app';
1515

1616
/**
1717
* Retrieve the version used by yarn and setup at root level
18-
* @param rootFolderPath: path to the folder where to take the configuration from
19-
* @param rootFolderPath
18+
* @param rootFolderPath path to the folder where to take the configuration from
2019
*/
2120
export function getYarnVersionFromRoot(rootFolderPath: string) {
2221
const o3rPackageJson: PackageJson & { generatorDependencies?: Record<string, string> } =
@@ -49,7 +48,7 @@ export async function prepareTestEnv(folderName: string, options?: PrepareTestEn
4948
const cacheFolderPath = path.resolve(globalFolderPath, 'cache');
5049

5150
JSON.parse(readFileSync(path.join(rootFolderPath, 'packages', '@o3r', 'core', 'package.json')).toString());
52-
const yarnVersion: string = yarnVersionParam || getYarnVersionFromRoot(rootFolderPath);
51+
const yarnVersion: string = yarnVersionParam || (isYarn1() && YARN_1_LATEST_VERSION) || getYarnVersionFromRoot(rootFolderPath);
5352
const execAppOptions: ExecSyncOptions = {
5453
cwd: workspacePath,
5554
stdio: 'inherit',

packages/@o3r/test-helpers/src/utilities/package-manager.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,19 @@ export function getPackageManager() {
4949
'yarn';
5050
}
5151

52+
53+
/**
54+
* latest version of yarn 1
55+
*/
56+
export const YARN_1_LATEST_VERSION = '1.22.19';
57+
58+
/**
59+
* is yarn 1
60+
*/
61+
export function isYarn1() {
62+
return process.env.ENFORCED_PACKAGE_MANAGER === 'yarn1';
63+
}
64+
5265
/**
5366
* Need to add additional dashes when running command like exec on npm
5467
* Convert `npm exec test --param` to `npm exec test -- --param`

0 commit comments

Comments
 (0)