Skip to content

Commit

Permalink
Merge branch 'release/10.0.0-next' into chore/vscode-nesting
Browse files Browse the repository at this point in the history
  • Loading branch information
kpanot authored Dec 13, 2023
2 parents f243586 + 32a9773 commit 8e957b3
Show file tree
Hide file tree
Showing 14 changed files with 110 additions and 13 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"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)",
"lint:affected": "yarn nx affected --target=lint --parallel $(yarn get:cpus-number)",
"test": "yarn nx run-many --target=test --parallel 2 --cacheDirectory=$(yarn get:current-dir)/.cache/jest",
"test:affected": "yarn nx affected --target=test --parallel 2 --cacheDirectory=$(yarn get:current-dir)/.cache/jest",
"test": "yarn nx run-many --target=test --parallel $(yarn get:cpus-number) --cacheDirectory=$(yarn get:current-dir)/.cache/jest",
"test:affected": "yarn nx affected --target=test --parallel $(yarn get:cpus-number) --cacheDirectory=$(yarn get:current-dir)/.cache/jest",
"test-int": "yarn nx run-many --target=test-int --parallel 2",
"postinstall": "husky install && yarn build:tools && yarn harmonize:version",
"build:storybook": "yarn doc:generate:json && yarn ng run storybook:extract-style && build-storybook",
Expand Down
15 changes: 15 additions & 0 deletions packages/@o3r/create/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,25 @@ module.exports = {
'tsconfigRootDir': __dirname,
'project': [
'tsconfig.build.json',
'tsconfig.spec.json',
'tsconfig.eslint.json'
],
'sourceType': 'module'
},
'overrides': [
{
'files': [
'**/package.json'
],
'rules': {
'@nx/dependency-checks': ['error', {
'buildTargets': ['build', 'compile', 'test'],
'ignoredDependencies': ['@o3r/test-helpers'],
'checkObsoleteDependencies': false
}]
}
}
],
'extends': [
'../../../.eslintrc.js'
]
Expand Down
4 changes: 3 additions & 1 deletion packages/@o3r/create/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"dependencies": {
"@angular/cli": "~17.0.3",
"@schematics/angular": "~17.0.3",
"minimist": "^1.2.6"
"minimist": "^1.2.6",
"tslib": "^2.5.3"
},
"devDependencies": {
"@angular-eslint/eslint-plugin": "~17.1.0",
Expand All @@ -29,6 +30,7 @@
"@o3r/build-helpers": "workspace:^",
"@o3r/eslint-config-otter": "workspace:^",
"@o3r/eslint-plugin": "workspace:^",
"@o3r/test-helpers": "workspace:^",
"@types/jest": "~29.5.2",
"@types/minimist": "^1.2.2",
"@types/node": "^18.0.0",
Expand Down
7 changes: 7 additions & 0 deletions packages/@o3r/create/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@
]
}
},
"test-int": {
"executor": "@nx/jest:jest",
"options": {
"jestConfig": "packages/@o3r/create/testing/jest.config.it.js",
"silent": false
}
},
"prepare-publish": {
"executor": "nx:run-script",
"options": {
Expand Down
35 changes: 35 additions & 0 deletions packages/@o3r/create/src/index.it.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import {
getDefaultExecSyncOptions,
getPackageManager,
getYarnVersionFromRoot,
packageManagerCreate,
packageManagerExec,
packageManagerInstall,
prepareTestEnv,
setupLocalRegistry
} from '@o3r/test-helpers';
import * as path from 'node:path';

const appName = 'test-create-app';
let baseFolderPath: string;
let appPackagePath: string;
const execAppOptions = getDefaultExecSyncOptions();
const packageManager = getPackageManager();

describe('Create new otter project command', () => {
setupLocalRegistry();
beforeEach(async () => {
const isYarnTest = packageManager.startsWith('yarn');
const yarnVersion = isYarnTest ? getYarnVersionFromRoot(process.cwd()) || 'latest' : undefined;
baseFolderPath = await prepareTestEnv(appName, 'blank', yarnVersion);
appPackagePath = path.join(baseFolderPath, appName);
execAppOptions.cwd = baseFolderPath;
});

test('should generate a project with an application', () => {
expect(() => packageManagerCreate(`@o3r ${appName}`, execAppOptions)).not.toThrow();
expect(() => packageManagerInstall({ ...execAppOptions, cwd: appPackagePath })).not.toThrow();
expect(() => packageManagerExec('ng g application my-app', { ...execAppOptions, cwd: appPackagePath })).not.toThrow();
expect(() => packageManagerExec('ng build my-app', { ...execAppOptions, cwd: appPackagePath })).not.toThrow();
});
});
19 changes: 16 additions & 3 deletions packages/@o3r/create/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,25 @@ const isNgNewOptions = (arg: string) => {
if (arg.startsWith('--')) {
return entries.some(([key]) => [`--${key}`, `--no-${key}`, `--${key.replaceAll(/([A-Z])/g, '-$1').toLowerCase()}`, `--no-${key.replaceAll(/([A-Z])/g, '-$1').toLowerCase()}`].includes(arg));
} else if (arg.startsWith('-')) {
return entries.some(([_, {alias}]) => alias && arg === `-${alias}`);
return entries.some(([, {alias}]) => alias && arg === `-${alias}`);
}

return true;
};

const schematicsCliOptions: any[][] = Object.entries(argv)
.filter(([key]) => key !== '_')
.map(([key, value]) => value === true && [key] || value === false && key.length > 1 && [`no-${key}`] || [key, value])
.map(([key, value]) => {
const optionKey = key.length > 1 ? `--${key}` : `-${key}`;
return typeof value === 'undefined' ? [optionKey] : [optionKey, value];
});

const createNgProject = () => {
const { error } = spawnSync(process.execPath, [binPath, 'new', ...args.filter(isNgNewOptions), '--skip-install'], {
const options = schematicsCliOptions
.filter(([key]) => isNgNewOptions(key))
.flat();
const { error } = spawnSync(process.execPath, [binPath, 'new', ...argv._, ...options, '--skip-install'], {
stdio: 'inherit'
});

Expand All @@ -128,7 +139,9 @@ const createNgProject = () => {

const addOtterFramework = (relativeDirectory = '.') => {
const cwd = resolve(process.cwd(), relativeDirectory);
const { error } = spawnSync(process.execPath, [binPath, 'add', `@o3r/core@${version || 'latest'}`, ...args.filter((arg) => arg.startsWith('-'))], {
const options = schematicsCliOptions
.flat();
const { error } = spawnSync(process.execPath, [binPath, 'add', `@o3r/core@${version || 'latest'}`, ...options], {
stdio: 'inherit',
cwd
});
Expand Down
8 changes: 8 additions & 0 deletions packages/@o3r/create/testing/jest.config.it.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const { dirname } = require('node:path');
const getJestConfig = require('../../../../jest.config.it').getJestConfig;

/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */
module.exports = {
...getJestConfig(dirname(__dirname)),
displayName: require('../package.json').name
};
3 changes: 3 additions & 0 deletions packages/@o3r/create/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@
},
"include": [
"src/**/*.ts"
],
"exclude": [
"src/**/*.spec.ts"
]
}
3 changes: 3 additions & 0 deletions packages/@o3r/create/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"references": [
{
"path": "./tsconfig.build.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}
12 changes: 12 additions & 0 deletions packages/@o3r/create/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "../../../tsconfig.jest",
"compilerOptions": {
"incremental": true,
"composite": true,
"outDir": "test",
"rootDir": "."
},
"include": [
"./src/**/*.spec.ts"
]
}
4 changes: 2 additions & 2 deletions packages/@o3r/test-helpers/src/public_api.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './prepare-test-env';
export * from './test-environments';
export * from './utilities';
export * from './test-environments/index';
export * from './utilities/index';
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const PACKAGE_MANAGERS_CMD = {
yarn: {
add: 'yarn add',
create: 'yarn create',
exec: 'yarn exec',
exec: 'yarn',
install: 'yarn install',
run: 'yarn run',
workspaceExec: 'yarn workspace',
Expand Down
5 changes: 1 addition & 4 deletions packages/@o3r/test-helpers/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
},
"include": ["src/**/*.ts"],
"exclude": [
"**/*.spec.ts",
"src/**/fixtures/**/*.ts",
"src/builders/**/*.ts",
"src/helpers/**/*.ts"
"**/*.spec.ts"
]
}
2 changes: 2 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6962,6 +6962,7 @@ __metadata:
"@o3r/build-helpers": "workspace:^"
"@o3r/eslint-config-otter": "workspace:^"
"@o3r/eslint-plugin": "workspace:^"
"@o3r/test-helpers": "workspace:^"
"@schematics/angular": "npm:~17.0.3"
"@types/jest": "npm:~29.5.2"
"@types/minimist": "npm:^1.2.2"
Expand All @@ -6983,6 +6984,7 @@ __metadata:
rimraf: "npm:^5.0.1"
rxjs: "npm:^7.8.1"
ts-jest: "npm:~29.1.1"
tslib: "npm:^2.5.3"
type-fest: "npm:^3.12.0"
typescript: "npm:~5.2.2"
bin:
Expand Down

0 comments on commit 8e957b3

Please sign in to comment.