Skip to content

Commit

Permalink
[cascading] from release/10.3 to release/10.4.0-rc (#1838)
Browse files Browse the repository at this point in the history
<!--
{"currentBranch":"release/10.3","targetBranch":"release/10.4.0-rc","bypassReviewers":false,"isConflicting":false}
-->

## Cascading from release/10.3 to release/10.4.0-rc





---

:heavy_exclamation_mark: The pull request is conflicting with the target
branch.
You can fix the issue locally with the following commands:

<details open>
  <summary>Using <b>gh CLI</b></summary>

  ```shell
  gh pr checkout 1838
  git pull --ff origin release/10.4.0-rc
  ```

  and update this Pull Request with

  ```shell
  gh pr push 1838
  ```
</details>

<details>
  <summary>Using <b>git</b> only</summary>

  ```shell
  git fetch origin
  git checkout origin/cascading/10.3.0-10.4.0-rc
  git pull --ff origin release/10.4.0-rc
  ```

  and update this Pull Request with

  ```shell
  git push origin HEAD:cascading/10.3.0-10.4.0-rc
  ```
</details>



---

<small>This Pull Request has been generated with :heart: by the
[Otter](https://github.com/AmadeusITGroup/otter) cascading tool.</small>
  • Loading branch information
mrednic-1A authored Jun 3, 2024
2 parents 04e102c + dd6d8a3 commit 24ea375
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 7 deletions.
5 changes: 5 additions & 0 deletions packages/@ama-sdk/schematics/migration.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
"version": "10.0.0-alpha.0",
"description": "Updates of @ama-sdk/schematics to v10.0.*",
"factory": "./schematics/ng-update/index#updateV10_0"
},
"migration-v10_3": {
"version": "10.3.0-alpha.0",
"description": "Updates of @ama-sdk/schematics to v10.3.*",
"factory": "./schematics/ng-update/index#updateV10_3"
}
}
}
8 changes: 6 additions & 2 deletions packages/@ama-sdk/schematics/schematics/migrate/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@ import { getMigrationRuleRunner, getWorkspaceConfig, type MigrationRulesMap } fr
import { resolve } from 'node:path';
import { gt, minVersion } from 'semver';
import { isTypescriptSdk } from '../helpers/is-typescript-project';
import {updateOpenApiVersionInProject} from '../ng-update/typescript/v10.3/update-openapiversion';

/* eslint-disable @typescript-eslint/naming-convention */
const tsMigrationMap: MigrationRulesMap = {

'~10.3.2': updateOpenApiVersionInProject()
};
/* eslint-enable @typescript-eslint/naming-convention */

/**
* Facilitate the migration of a version to another by the run of migration rules
* @param options
*/
function migrateFn(options: MigrateSchematicsSchemaOptions): Rule {

const currentVersion = JSON.parse(require(resolve(__dirname, '..', '..', 'package.json'))).version;
const currentVersion = require(resolve(__dirname, '..', '..', 'package.json')).version;
const to: string = options.to || currentVersion;
const minimumVersion = minVersion(to);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { chain, Rule } from '@angular-devkit/schematics';
import { addCpyDependencies, deprecateScriptsFolder, updateScriptPackageJson } from './v10.0/script-removal';
import { addPresetsRenovate } from './v10.1/add-presets-renovate';
import {updateOpenApiVersionInProject} from './v10.3/update-openapiversion';

/**
* update of Otter library V10.0
Expand All @@ -28,3 +29,14 @@ export function updateV10_1(): Rule {

return chain(updateRules);
}

/**
* Update of Ama-sdk library V10.3
*/
export function updateV10_3(): Rule {
const updateRules: Rule[] = [
updateOpenApiVersionInProject()
];

return chain(updateRules);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import type {Rule} from '@angular-devkit/schematics';
import * as semver from 'semver';
import {getWorkspaceConfig, globInTree} from '@o3r/schematics';
import {chain} from '@angular-devkit/schematics';

/**
* Update open api version used in the project to match with the one used in @ama-sdk/schematics:typescript-core
*/
export const updateOpenApiVersionInProject = (): Rule => {
const overwriteOpenApiVersion = (pathOfWorkspace: string): Rule => {
return (tree, context) => {
const packageJson = tree.readText(`${pathOfWorkspace}/package.json`);
const amaSdkTypescriptUsage = packageJson.match(/@ama-sdk\/schematics:typescript-core.*",?$/mg);
if (!amaSdkTypescriptUsage) {
context.logger.info(`Skipping ng-update for ${pathOfWorkspace} as it does not use @ama-sdk/schematics:typescript-core`);
return tree;
}
const openapitoolsPaths: string[] = [];
amaSdkTypescriptUsage.forEach((script) => {
const openapiToolsPath = new RegExp(/@ama-sdk\/schematics:typescript-core.* --spec-config-path(?:=|\s+)["']?(?:\.\/)?([a-zA-Z-/.0-9_]*\.json)/).exec(script);
if (openapiToolsPath?.length === 2) {
openapitoolsPaths.push(`${pathOfWorkspace}/${openapiToolsPath[1]}`);
}
});
if (amaSdkTypescriptUsage.length > openapitoolsPaths.length) {
openapitoolsPaths.push(`${pathOfWorkspace}/openapitools.json`);
}
(openapitoolsPaths || []).forEach((path) => {
if (!tree.exists(path)) {
context.logger.warn(`Missing ${path} file described in the package json.`);
return;
}
const openApiToolsConfig = tree.readJson(path) as any;
openApiToolsConfig['generator-cli'] ||= {};
if (!openApiToolsConfig['generator-cli'].version || !semver.satisfies(openApiToolsConfig['generator-cli'].version, '~7.4.0')) {
context.logger.info(`The following file will be updated to target open api tools version 7.4: ${path}`);
openApiToolsConfig['generator-cli'].version = '7.4.0';
tree.overwrite(path, JSON.stringify(openApiToolsConfig, null, 2));
}
}
);
return tree;
};
};

return (tree, context) => {
const pathsPackageJson = ['.'];
if (!tree.exists('package.json')) {
context.logger.error('Could not find a package.json file, make sure to run the ng-update at the root of typescript project');
}
const cwdPackageJson = tree.readJson('package.json') as any;
if (tree.exists('angular.json')) {
const workspaceConfig = getWorkspaceConfig(tree);
pathsPackageJson.push(...Object.values(workspaceConfig?.projects || {}).map((project) => project.root));
} else if (cwdPackageJson.workspaces) {
context.logger.info('Workspaces detected outside an angular project, running the update on the workspaces');
pathsPackageJson.push(...cwdPackageJson.workspaces.reduce((paths: string[], workspace: string) => {
if (workspace.includes('*')) {
paths.push(
...globInTree(tree, [`**/${workspace}/package.json`]).map((path) => path.replace('/package.json', ''))
);
} else {
paths.push(workspace);
}
return paths;
}, []));
}
return chain(
pathsPackageJson.map((pathPackageJson) =>
overwriteOpenApiVersion(pathPackageJson.at(pathPackageJson.length - 1) === '/' ? pathPackageJson.trim() : pathPackageJson)
)
);
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ export class O3rLocalizationTranslatePipe extends TranslatePipe implements PipeT
if (this.onShowKeysChange) {
this.onShowKeysChange.unsubscribe();
}
if (this.onKeyChange) {
this.onKeyChange.unsubscribe();
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/@o3r/schematics/src/utility/monorepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function isStandaloneRepository(tree: Tree) {
* @param tree
*/
export function isMultipackagesContext(tree: Tree) {
return !!(tree.readJson('/package.json') as PackageJson).wokspaces;
return !!(tree.readJson('/package.json') as PackageJson).workspaces;
}

/** Default name of the folder where libraries will be generated inside monorepo */
Expand Down
18 changes: 14 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4349,9 +4349,9 @@ __metadata:
linkType: hard

"@floating-ui/utils@npm:^0.2.0":
version: 0.2.2
resolution: "@floating-ui/utils@npm:0.2.2"
checksum: 10/28d900d2f0876b40c7090f55724700eeac608862e59110b7b14731223218cf7ce125b2091f34103edf4b0f779166151bbca21256b856236235a2be996548ed38
version: 0.2.1
resolution: "@floating-ui/utils@npm:0.2.1"
checksum: 10/33c9ab346e7b05c5a1e6a95bc902aafcfc2c9d513a147e2491468843bd5607531b06d0b9aa56aa491cbf22a6c2495c18ccfc4c0344baec54a689a7bb8e4898d6
languageName: node
linkType: hard

Expand Down Expand Up @@ -4838,7 +4838,17 @@ __metadata:
languageName: node
linkType: hard

"@jridgewell/trace-mapping@npm:^0.3.12, @jridgewell/trace-mapping@npm:^0.3.17, @jridgewell/trace-mapping@npm:^0.3.18, @jridgewell/trace-mapping@npm:^0.3.20, @jridgewell/trace-mapping@npm:^0.3.24, @jridgewell/trace-mapping@npm:^0.3.25":
"@jridgewell/trace-mapping@npm:^0.3.12, @jridgewell/trace-mapping@npm:^0.3.17, @jridgewell/trace-mapping@npm:^0.3.18, @jridgewell/trace-mapping@npm:^0.3.20":
version: 0.3.22
resolution: "@jridgewell/trace-mapping@npm:0.3.22"
dependencies:
"@jridgewell/resolve-uri": "npm:^3.1.0"
"@jridgewell/sourcemap-codec": "npm:^1.4.14"
checksum: 10/48d3e3db00dbecb211613649a1849876ba5544a3f41cf5e6b99ea1130272d6cf18591b5b67389bce20f1c871b4ede5900c3b6446a7aab6d0a3b2fe806a834db7
languageName: node
linkType: hard

"@jridgewell/trace-mapping@npm:^0.3.24, @jridgewell/trace-mapping@npm:^0.3.25":
version: 0.3.25
resolution: "@jridgewell/trace-mapping@npm:0.3.25"
dependencies:
Expand Down

0 comments on commit 24ea375

Please sign in to comment.