Skip to content

Commit

Permalink
Merge branch 'main' into cascading/10.3.0-rc-main
Browse files Browse the repository at this point in the history
  • Loading branch information
mrednic-1A authored May 16, 2024
2 parents 813293f + 5fbacc5 commit 5f01fb7
Show file tree
Hide file tree
Showing 58 changed files with 2,484 additions and 1,472 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/1-O3R-ISSUE-FORM.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Bug Report on @o3r
description: File a bug report on @o3r scope
title: "[Bug]: "
labels: ["bug", "o3r"]
labels: ["bug", "o3r", "triage"]
body:
- type: markdown
attributes:
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/2-AMA-SDK-ISSUE-FORM.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Bug Report on @ama-sdk
description: File a bug report on @ama-sdk scope
title: "[Bug]: "
labels: ["bug", "ama-sdk"]
labels: ["bug", "ama-sdk", "triage"]
body:
- type: markdown
attributes:
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/3-AMA-TERASU-ISSUE-FORM.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Bug Report on @ama-terasu
description: File a bug report on @ama-terasu scope
title: "[Bug]: "
labels: ["bug", "ama-terasu"]
labels: ["bug", "ama-terasu", "triage"]
body:
- type: markdown
attributes:
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/4-APPLICATION-ISSUE-FORM.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Bug Report to an Application from the Otter project
description: File a bug report on an Application from the Otter project
title: "[Bug]: "
labels: ["bug"]
labels: ["bug", "triage"]
body:
- type: markdown
attributes:
Expand Down
15 changes: 10 additions & 5 deletions .github/workflows/tests-reporter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ on:
types:
- completed

permissions:
contents: read
actions: read
checks: write

jobs:
publish-ut-reports:
runs-on: ubuntu-latest
permissions:
contents: read
actions: read
# Required to publish Unit Test Report to the pipelne execution result
checks: write
steps:
- uses: dorny/test-reporter@c40d89d5e987cd80f3a32b3c233556e22bdca958 # v1.9.0
with:
Expand All @@ -24,6 +24,11 @@ jobs:

publish-it-reports:
runs-on: ubuntu-latest
permissions:
contents: read
actions: read
# Required to publish Integration Test Report to the pipelne execution result
checks: write
steps:
- uses: dorny/test-reporter@c40d89d5e987cd80f3a32b3c233556e22bdca958 # v1.9.0
with:
Expand Down
16 changes: 16 additions & 0 deletions .renovaterc.json5
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,22 @@
],
"enabled": false
},
{
// Reduce the updates on Next to let them handle by the Main branch
"matchUpdateTypes": [
"bump",
"digest",
"lockFileMaintenance",
"minor",
"patch",
"pinDigest"
],
"matchBaseBranches": [
"/.*-next$/"
],
"enabled": false
},

{
// This rule disable the upgrade of the gaurav-nelson/github-action-markdown-link-check
// TODO: re-activate the upgrade when the following issue is fixed: gaurav-nelson/github-action-markdown-link-check#200
Expand Down
593 changes: 297 additions & 296 deletions .yarn/releases/yarn-4.1.1.cjs → .yarn/releases/yarn-4.2.2.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ packageExtensions:
dependencies:
"@ng-select/ng-select": "~12.0.7"

yarnPath: .yarn/releases/yarn-4.1.1.cjs
yarnPath: .yarn/releases/yarn-4.2.2.cjs
2 changes: 1 addition & 1 deletion apps/intellij-extension/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id("java")
id("org.jetbrains.kotlin.jvm") version "1.9.23"
id("org.jetbrains.kotlin.jvm") version "1.9.24"
id("org.jetbrains.intellij") version "1.17.3"
}

Expand Down
2 changes: 1 addition & 1 deletion apps/showcase/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"@o3r/eslint-plugin": "workspace:^",
"@o3r/schematics": "workspace:^",
"@o3r/testing": "workspace:^",
"@playwright/test": "~1.43.0",
"@playwright/test": "~1.44.0",
"@schematics/angular": "~17.3.0",
"@stylistic/eslint-plugin-ts": "^1.5.4",
"@types/bootstrap": "^5.2.10",
Expand Down
13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"build:lint": "yarn nx run-many --target=build --projects=eslint-plugin --parallel $(yarn get:cpus-number)",
"build:swagger-gen": "yarn nx run-many --target=build-swagger --parallel $(yarn get:cpus-number)",
"prepare:publish": "yarn prepare-publish \"$(yarn workspaces:list)\" --append dist",
"publish": "yarn run prepare:publish && yarn nx run-many --target=publish --parallel $(yarn get:cpus-number) --nx-bail",
"publish": "yarn run prepare:publish && yarn nx run-many --target=publish --exclude=tag:private --parallel $(yarn get:cpus-number) --nx-bail",
"publish:extensions": "yarn nx run-many --target=publish-extension --parallel $(yarn get:cpus-number)",
"publish:extensions:affected": "yarn nx affected --target=publish-extension --parallel $(yarn get:cpus-number)",
"lint": "yarn nx run-many --target=lint --parallel $(yarn get:cpus-number)",
Expand All @@ -41,7 +41,8 @@
"verdaccio:start-persistent": "docker run -d -it --rm --name verdaccio -p 4873:4873 -v \"$(yarn get:current-dir)/.verdaccio/conf\":/verdaccio/conf -v \"$(yarn get:current-dir)/.verdaccio/storage\":/verdaccio/storage:z verdaccio/verdaccio",
"verdaccio:clean": "rimraf -g \".verdaccio/storage/@{o3r,ama-sdk,ama-terasu}\"",
"verdaccio:login": "yarn cpy --cwd=./.verdaccio/conf .npmrc . --rename=.npmrc-logged && npx --yes npm-cli-login -u verdaccio -p verdaccio -e [email protected] -r http://127.0.0.1:4873 --config-path \".verdaccio/conf/.npmrc-logged\"",
"verdaccio:publish": "yarn verdaccio:clean && yarn set:version 999.0.$(node -e 'process.stdout.write(String(Date.now()))') --include \"!**/!(dist)/package.json\" --include !package.json && yarn verdaccio:login && yarn run publish --userconfig \".verdaccio/conf/.npmrc-logged\" --tag=latest --@o3r:registry=http://127.0.0.1:4873 --@ama-sdk:registry=http://127.0.0.1:4873 --@ama-terasu:registry=http://127.0.0.1:4873",
"verdaccio:prepare-publish": "yarn verdaccio:clean && yarn set:version 999.0.$(node -e 'process.stdout.write(String(Date.now()))') --include \"!**/!(dist)/package.json\" --include !package.json && yarn verdaccio:login && replace-in-files --regex=\"private(.*)true\" --replacement=private\\$1false '**/dist/package.json' && yarn run prepare:publish",
"verdaccio:publish": "yarn run verdaccio:prepare-publish && yarn nx run-many --target=publish --parallel $(yarn get:cpus-number) --nx-bail --userconfig \".verdaccio/conf/.npmrc-logged\" --tag=latest --@o3r:registry=http://127.0.0.1:4873 --@ama-sdk:registry=http://127.0.0.1:4873 --@ama-terasu:registry=http://127.0.0.1:4873",
"verdaccio:stop": "docker container stop $(docker ps -a -q --filter=\"name=verdaccio\")",
"verdaccio:all": "yarn verdaccio:stop && yarn verdaccio:start && yarn verdaccio:publish",
"watch:vscode-extension": "yarn nx run vscode-extension:compile:watch",
Expand Down Expand Up @@ -187,7 +188,7 @@
"@o3r/eslint-plugin": "workspace:^",
"@o3r/telemetry": "workspace:^",
"@o3r/workspace": "workspace:^",
"@playwright/test": "~1.43.0",
"@playwright/test": "~1.44.0",
"@popperjs/core": "^2.11.5",
"@schematics/angular": "~17.3.0",
"@stylistic/eslint-plugin-ts": "^1.5.4",
Expand Down Expand Up @@ -238,6 +239,7 @@
"postcss-scss": "~4.0.9",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"replace-in-files-cli": "^2.2.0",
"rimraf": "^5.0.1",
"sass": "~1.76.0",
"sass-loader": "^14.0.0",
Expand All @@ -255,6 +257,9 @@
"yaml-eslint-parser": "^1.2.2"
},
"dependenciesMeta": {
"@swc/core": {
"built": true
},
"esbuild": {
"built": true
}
Expand All @@ -272,5 +277,5 @@
"tools/@*/*",
"apps/*"
],
"packageManager": "yarn@4.1.1"
"packageManager": "yarn@4.2.2"
}
13 changes: 13 additions & 0 deletions packages/@ama-sdk/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Please refer to the [ama-sdk-schematics](../schematics/README.md) package for ge

## Available plugins

- [abort](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/core/src/plugins/abort)
- [additional-params](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/core/src/plugins/additional-params)
- [api-configuration-override](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/core/src/plugins/api-configuration-override)
- [api-key](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/core/src/plugins/api-key)
Expand Down Expand Up @@ -69,3 +70,15 @@ function petApiFactory() {
```

> *Note*: Adding a third-party logging service is optional. If undefined, the fallback is the console logger.
### CLI

This package also comes with CLI scripts that can facilitate the upgrade and publication of an SDK.
Use --help on each command for more information

| Script | Description |
|-----------------------------|------------------------------------------------------------------------------------------------|
| amasdk-clear-index | Remove the index files that are no longer necessary after the deletion of the associated model |
| amasdk-files-pack | Prepare the dist folder for publication |
| amasdk-update-spec-from-npm | Update the OpenAPI spec from an NPM package |

10 changes: 10 additions & 0 deletions packages/@ama-sdk/core/cli/clear-index.cts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,21 @@
* Remove deleted models' exports
*/

import * as minimist from 'minimist';
import { promises as fs, statSync } from 'node:fs';
import { resolve } from 'node:path';

const argv = minimist(process.argv.slice(2));
const { help } = argv;
const baseDir = resolve(process.cwd(), 'src', 'models', 'base');

if (help) {
console.log(`Remove the index files that are no longer necessary after the deletion of the associated model.
Usage: amasdk-clear-index
`);
process.exit(0);
}

void (async () => {
const models = await fs.readdir(baseDir);
const shouldRemoveModels = (
Expand Down
18 changes: 15 additions & 3 deletions packages/@ama-sdk/core/cli/files-pack.cts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,17 @@ import type { PackageJson } from 'type-fest';
const argv = minimist(process.argv.slice(2));
const distFolder = argv.dist || 'dist';
const baseDir = argv.cwd && path.resolve(process.cwd(), argv.cwd) || process.cwd();
const {watch, noExports} = argv;
const {help, watch, noExports} = argv;

if (help) {
console.log(`Prepare the dist folder for publication. This will copy necessary files from src and update the exports in package.json.
Usage: amasdk-files-pack [--exports] [--watch]
--exports Update the exports in package.json. (Default: true)
--watch Watch for files changes and run the updates
`);
process.exit(0);
}

const files = [
{glob: 'README.md', cwdForCopy: baseDir},
Expand Down Expand Up @@ -71,10 +81,12 @@ void (async () => {
return watch ?
import('chokidar')
.then((chokidar) => chokidar.watch(glob, {cwd: baseDir}))
.then((watcher) => watcher.on('all', (event, file) => {
.then((watcher) => watcher.on('all', async (event, file) => {
if (event !== 'unlink' && event !== 'unlinkDir') {
copyToDist(file, cwdForCopy);
return updateExports();
if (!noExports) {
await updateExports();
}
}
})) :
globby.sync(glob)
Expand Down
74 changes: 74 additions & 0 deletions packages/@ama-sdk/core/cli/update-spec-from-npm.cts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/env node

/*
* Update the OpenAPI spec from an NPM package
*/

import * as minimist from 'minimist';
import { existsSync } from 'node:fs';
import { createRequire } from 'node:module';
import { extname, join } from 'node:path';
import { copyFile, readFile } from 'node:fs/promises';
import type { PackageJson } from 'type-fest';
import type { OpenApiToolsConfiguration } from '../src/fwk/open-api-tools-configuration';

const argv = minimist(process.argv.slice(2));
const packageName = argv._[0];
const { help, output, 'package-path': packagePath, quiet } = argv;
const openApiConfigDefaultPath = './openapitools.json';
const supportedExtensions = ['json', 'yaml', 'yml'];
const noop = () => undefined;
const logger = quiet ? {error: noop, warn: noop, log: noop, info: noop, debug: noop} : console;

if (help) {
console.log(`This script can be used to update your local spec file from a given locally installed npm package.
Usage: amasdk-update-spec-from-npm <package-name> [--package-path] [--output] [--quiet]
package-name The full identifier of the npm package (e.g. @my-scope/my-package)
--package-path The relative path inside the npm package where to find the spec file (default: './openapi.yml')
--output The path where the spec file should be copied (default: './openapi.yml')
--quiet Don't log anything
`);
process.exit(0);
}

if (!packageName) {
logger.error('Need to provide packageName, use `amasdk-update-spec-from-npm --help` for more information');
process.exit(-1);
}

void (async () => {
let specSourcePath;
const appRequire = createRequire(join(process.cwd(), 'package.json'));
const packageJsonPath = appRequire.resolve(`${packageName}/package.json`);
if (!packagePath) {
const packageJson = JSON.parse(await readFile(packageJsonPath, {encoding: 'utf8'})) as PackageJson;
const exportMatcher = new RegExp(`openapi\\.(?:${supportedExtensions.join('|')})$`);
const matchingExport = packageJson.exports && Object.keys(packageJson.exports).find((exportPath) => exportMatcher.test(exportPath));
if (matchingExport) {
specSourcePath = appRequire.resolve(`${packageName}/${matchingExport}`);
}
} else {
specSourcePath = packageJsonPath.replace(/package.json$/, packagePath);
}
if (!specSourcePath || !existsSync(specSourcePath)) {
logger.error(`Unable to find source spec from ${packageName}, please make sure it is correctly exported in package.json`);
process.exit(-2);
}

let specDestinationPath = output;
if (!specDestinationPath) {
const specSourceExtension = extname(specSourcePath);
specDestinationPath = `./openapi${specSourceExtension}`;
if (existsSync(openApiConfigDefaultPath)) {
const openApiConfig = JSON.parse(await readFile(openApiConfigDefaultPath, {encoding: 'utf8'})) as OpenApiToolsConfiguration;
const generators = Object.values(openApiConfig['generator-cli']?.generators ?? {});
if (generators.length === 1 && generators[0].inputSpec && extname(generators[0].inputSpec) === specSourceExtension) {
specDestinationPath = generators[0].inputSpec;
}
}
}

logger.info(`Updating spec file from "${specSourcePath}" to "${specDestinationPath}" (CWD: "${process.cwd()}")`);
await copyFile(specSourcePath, specDestinationPath);
})();
3 changes: 2 additions & 1 deletion packages/@ama-sdk/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@
"schematics": "./collection.json",
"bin": {
"amasdk-clear-index": "./dist/cli/clear-index.cjs",
"amasdk-files-pack": "./dist/cli/files-pack.cjs"
"amasdk-files-pack": "./dist/cli/files-pack.cjs",
"amasdk-update-spec-from-npm": "./dist/cli/update-spec-from-npm.cjs"
}
}
1 change: 1 addition & 0 deletions packages/@ama-sdk/core/src/fwk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ export * from './errors';
export * from './ignore-enum.type';
export * from './logger';
export * from './mocks/index';
export * from './open-api-tools-configuration';
export * from './Reviver';
30 changes: 30 additions & 0 deletions packages/@ama-sdk/core/src/fwk/open-api-tools-configuration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/** Configuration of an Open API generator */
export interface OpenApiToolsGenerator {
/** Location of the OpenAPI spec, as URL or file */
inputSpec: string;
/** Output path for the generated SDK */
output: string;
/** Generator to use */
generatorName: string;
/** Path to configuration file. It can be JSON or YAML */
config?: string;
/** Sets specified global properties */
globalProperty?: string | Record<string, any>;
}

/** Global configuration of Open API generators */
export interface OpenApiToolsGeneratorCli {
/** Open API version */
version: string;
/** Location of the generator JAR file */
storageDir?: string;
/** Generators configuration */
generators: Record<string, OpenApiToolsGenerator>;
}

/** Global configuration of Open API Tools */
export interface OpenApiToolsConfiguration {
/** Generators CLI configuration */
// eslint-disable-next-line @typescript-eslint/naming-convention
'generator-cli': OpenApiToolsGeneratorCli;
}
Loading

0 comments on commit 5f01fb7

Please sign in to comment.