Skip to content

Commit

Permalink
fix(#2758): set exact-o3r-version as default for all schematics if pr…
Browse files Browse the repository at this point in the history
…ovided when adding @o3r/core
  • Loading branch information
matthieu-crouzet committed Jan 31, 2025
1 parent 54aabbb commit 5c3b77c
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 5 deletions.
3 changes: 3 additions & 0 deletions packages/@o3r/application/schematics/ng-add/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ function ngAddFn(options: NgAddSchematicsSchema): Rule {
getWorkspaceConfig,
insertImportToModuleFile,
setupDependencies,
getDefaultOptionsForSchematic,
getO3rPeerDeps,
getProjectNewDependenciesTypes,
getPackageInstallConfig
} = await import('@o3r/schematics');
options = {...getDefaultOptionsForSchematic(getWorkspaceConfig(tree), '@o3r/application', 'ng-add', options), ...options};

const { isImported } = await import('@schematics/angular/utility/ast-utils');
const ts = await import('typescript');
const packageJsonPath = path.resolve(__dirname, '..', '..', 'package.json');
Expand Down
3 changes: 1 addition & 2 deletions packages/@o3r/application/schematics/ng-add/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
},
"exactO3rVersion": {
"type": "boolean",
"description": "Use a pinned version for otter packages",
"default": false
"description": "Use a pinned version for otter packages"
}
},
"additionalProperties": true,
Expand Down
2 changes: 2 additions & 0 deletions packages/@o3r/core/schematics/ng-add/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ function ngAddFn(options: NgAddSchematicsSchema): Rule {
return chain([
// eslint-disable-next-line @typescript-eslint/naming-convention
setupSchematicsParamsForProject({ '*:ng-add': { registerDevtool: options.withDevtool } }, options.projectName),
// eslint-disable-next-line @typescript-eslint/naming-convention
options.exactO3rVersion ? setupSchematicsParamsForProject({ '*:*': { exactO3rVersion: true } }, options.projectName) : noop(),
options.projectName ? prepareProject(options, dependenciesSetupConfig) : noop(),
registerPackageCollectionSchematics(corePackageJsonContent),
async (t, c) => {
Expand Down
7 changes: 4 additions & 3 deletions packages/@o3r/create/src/index.it.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe('Create new otter project command', () => {
expect(() => packageManagerInstall(execInAppOptions)).not.toThrow();

const appName = 'test-application';
expect(() => packageManagerExec({ script: 'ng', args: ['g', 'application', appName, '--exact-o3r-version'] }, execInAppOptions)).not.toThrow();
expect(() => packageManagerExec({ script: 'ng', args: ['g', 'application', appName] }, execInAppOptions)).not.toThrow();
expect(existsSync(path.join(inProjectPath, 'project'))).toBe(false);
expect(() => packageManagerRunOnProject(appName, true, { script: 'build' }, execInAppOptions)).not.toThrow();

Expand All @@ -98,8 +98,9 @@ describe('Create new otter project command', () => {
[
...Object.entries(rootPackageJson.dependencies), ...Object.entries(rootPackageJson.devDependencies), ...Object.entries(resolutions),
...Object.entries(appPackageJson.dependencies), ...Object.entries(appPackageJson.devDependencies)
].filter(([dep]) => dep.startsWith('@o3r/') || dep.startsWith('@ama-sdk/')).forEach(([,version]) => {
expect(version).toBe(o3rExactVersion);
].filter(([dep]) => dep.startsWith('@o3r/') || dep.startsWith('@ama-sdk/')).forEach(([dep, version]) => {

Check failure on line 101 in packages/@o3r/create/src/index.it.spec.ts

View workflow job for this annotation

GitHub Actions / IT Tests report-ubuntu-latest-yarn

Create new otter project command ► Create new otter project command should generate a project with an application with --exact-o3r-version ► Create new otter project command should generate a project with an application with --exact-o3r-version

Failed test found in: @o3r/create/dist-test/it-report.xml Error: Error: expect(received).toBe(expected) // Object.is equality
Raw output
Error: expect(received).toBe(expected) // Object.is equality

Expected: "@o3r/application=999.0.1738317066962"
Received: "@o3r/application=~999.0.1738317066962"
    at /home/runner/work/otter/otter/packages/@o3r/create/src/index.it.spec.ts:103:45
    at Array.forEach (<anonymous>)
    at Object.<anonymous> (/home/runner/work/otter/otter/packages/@o3r/create/src/index.it.spec.ts:101:81)

Check failure on line 101 in packages/@o3r/create/src/index.it.spec.ts

View workflow job for this annotation

GitHub Actions / IT Tests report-ubuntu-latest-npm

Create new otter project command ► Create new otter project command should generate a project with an application with --exact-o3r-version ► Create new otter project command should generate a project with an application with --exact-o3r-version

Failed test found in: @o3r/create/dist-test/it-report.xml Error: Error: expect(received).toBe(expected) // Object.is equality
Raw output
Error: expect(received).toBe(expected) // Object.is equality

Expected: "@o3r/application=999.0.1738317066962"
Received: "@o3r/application=~999.0.1738317066962"
    at /home/runner/work/otter/otter/packages/@o3r/create/src/index.it.spec.ts:103:45
    at Array.forEach (<anonymous>)
    at Object.<anonymous> (/home/runner/work/otter/otter/packages/@o3r/create/src/index.it.spec.ts:101:81)
// Adding `dep` to simplify the debug
expect(`${dep}=${version as string}`).toBe(`${dep}=${o3rExactVersion}`);

Check failure on line 103 in packages/@o3r/create/src/index.it.spec.ts

View workflow job for this annotation

GitHub Actions / it-tests / it-tests (ubuntu-latest, yarn, o3r-project-with-app)

Create new otter project command › should generate a project with an application with --exact-o3r-version

expect(received).toBe(expected) // Object.is equality Expected: "@o3r/application=999.0.1738317066962" Received: "@o3r/application=~999.0.1738317066962" at src/index.it.spec.ts:103:45 at Array.forEach (<anonymous>) at Object.<anonymous> (src/index.it.spec.ts:101:81)

Check failure on line 103 in packages/@o3r/create/src/index.it.spec.ts

View workflow job for this annotation

GitHub Actions / it-tests / it-tests (ubuntu-latest, npm, o3r-project-with-app)

Create new otter project command › should generate a project with an application with --exact-o3r-version

expect(received).toBe(expected) // Object.is equality Expected: "@o3r/application=999.0.1738317066962" Received: "@o3r/application=~999.0.1738317066962" at src/index.it.spec.ts:103:45 at Array.forEach (<anonymous>) at Object.<anonymous> (src/index.it.spec.ts:101:81)

Check failure on line 103 in packages/@o3r/create/src/index.it.spec.ts

View workflow job for this annotation

GitHub Actions / it-tests / it-tests (windows-latest, yarn, o3r-project-with-app)

Create new otter project command › should generate a project with an application with --exact-o3r-version

expect(received).toBe(expected) // Object.is equality Expected: "@o3r/application=999.0.1738317066962" Received: "@o3r/application=~999.0.1738317066962" at src/index.it.spec.ts:103:45 at Array.forEach (<anonymous>) at Object.<anonymous> (src/index.it.spec.ts:101:81)

Check failure on line 103 in packages/@o3r/create/src/index.it.spec.ts

View workflow job for this annotation

GitHub Actions / it-tests / it-tests (windows-latest, npm, o3r-project-with-app)

Create new otter project command › should generate a project with an application with --exact-o3r-version

expect(received).toBe(expected) // Object.is equality Expected: "@o3r/application=999.0.1738317066962" Received: "@o3r/application=~999.0.1738317066962" at src/index.it.spec.ts:103:45 at Array.forEach (<anonymous>) at Object.<anonymous> (src/index.it.spec.ts:101:81)
});
});
});
27 changes: 27 additions & 0 deletions tools/github-actions/new-version/packaged-action/LICENSE.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5c3b77c

Please sign in to comment.