Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into release-version-p…
Browse files Browse the repository at this point in the history
…ublish-handling
  • Loading branch information
JamesHenry committed Jan 26, 2024
2 parents f3f1c37 + fc8cca4 commit c2fb4ac
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 16 deletions.
12 changes: 6 additions & 6 deletions packages/cypress/src/plugins/plugin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ describe('@nx/cypress/plugin', () => {
"targets": {
"e2e": {
"cache": true,
"command": "cypress run --config-file cypress.config.js --e2e",
"command": "cypress run",
"configurations": {
"production": {
"command": "cypress run --config-file cypress.config.js --e2e --env webServerCommand="nx run my-app:serve:production"",
"command": "cypress run --env webServerCommand="nx run my-app:serve:production"",
},
},
"inputs": [
Expand Down Expand Up @@ -132,7 +132,7 @@ describe('@nx/cypress/plugin', () => {
"targets": {
"component-test": {
"cache": true,
"command": "cypress open --config-file cypress.config.js --component",
"command": "cypress open --component",
"inputs": [
"default",
"^production",
Expand Down Expand Up @@ -190,10 +190,10 @@ describe('@nx/cypress/plugin', () => {
"targets": {
"e2e": {
"cache": true,
"command": "cypress run --config-file cypress.config.js --e2e",
"command": "cypress run",
"configurations": {
"production": {
"command": "cypress run --config-file cypress.config.js --e2e --env webServerCommand="my-app:serve:production"",
"command": "cypress run --env webServerCommand="my-app:serve:production"",
},
},
"inputs": [
Expand Down Expand Up @@ -239,7 +239,7 @@ describe('@nx/cypress/plugin', () => {
},
"e2e-ci--src/test.cy.ts": {
"cache": true,
"command": "cypress run --config-file cypress.config.js --e2e --env webServerCommand="my-app:serve-static" --spec src/test.cy.ts",
"command": "cypress run --env webServerCommand="my-app:serve-static" --spec src/test.cy.ts",
"inputs": [
"default",
"^production",
Expand Down
14 changes: 6 additions & 8 deletions packages/cypress/src/plugins/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const createDependencies: CreateDependencies = () => {
};

export const createNodes: CreateNodes<CypressPluginOptions> = [
'**/cypress.config.{js,ts,mjs,mts,cjs,cts}',
'**/cypress.config.{js,ts,mjs,cjs}',
(configFilePath, options, context) => {
options = normalizeOptions(options);
const projectRoot = dirname(configFilePath);
Expand Down Expand Up @@ -157,15 +157,13 @@ function buildCypressTargets(
const webServerCommands: Record<string, string> =
pluginPresetOptions?.webServerCommands;

const relativeConfigPath = relative(projectRoot, configFilePath);

const namedInputs = getNamedInputs(projectRoot, context);

const targets: Record<string, TargetConfiguration> = {};

if ('e2e' in cypressConfig) {
targets[options.targetName] = {
command: `cypress run --config-file ${relativeConfigPath} --e2e`,
command: `cypress run`,
options: { cwd: projectRoot },
cache: true,
inputs: getInputs(namedInputs),
Expand All @@ -182,7 +180,7 @@ function buildCypressTargets(
webServerCommands ?? {}
)) {
targets[options.targetName].configurations[configuration] = {
command: `cypress run --config-file ${relativeConfigPath} --e2e --env webServerCommand="${webServerCommand}"`,
command: `cypress run --env webServerCommand="${webServerCommand}"`,
};
}
}
Expand Down Expand Up @@ -215,7 +213,7 @@ function buildCypressTargets(
outputs,
inputs,
cache: true,
command: `cypress run --config-file ${relativeConfigPath} --e2e --env webServerCommand="${ciWebServerCommand}" --spec ${relativeSpecFilePath}`,
command: `cypress run --env webServerCommand="${ciWebServerCommand}" --spec ${relativeSpecFilePath}`,
options: {
cwd: projectRoot,
},
Expand All @@ -241,7 +239,7 @@ function buildCypressTargets(
if ('component' in cypressConfig) {
// This will not override the e2e target if it is the same
targets[options.componentTestingTargetName] ??= {
command: `cypress open --config-file ${relativeConfigPath} --component`,
command: `cypress open --component`,
options: { cwd: projectRoot },
cache: true,
inputs: getInputs(namedInputs),
Expand All @@ -259,7 +257,7 @@ function getCypressConfig(
const resolvedPath = join(context.workspaceRoot, configFilePath);

let module: any;
if (['.ts', '.mts', '.cts'].includes(extname(configFilePath))) {
if (extname(configFilePath) === '.ts') {
const tsConfigPath = getRootTsConfigPath();

if (tsConfigPath) {
Expand Down
2 changes: 1 addition & 1 deletion packages/nx/src/tasks-runner/forked-process-task-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ export class ForkedProcessTaskRunner {
}
});
// we exit here because we don't need to write anything to cache.
process.exit();
process.exit(this.signalToCode('SIGINT'));
});
process.on('SIGTERM', () => {
this.processes.forEach((p) => {
Expand Down
17 changes: 16 additions & 1 deletion scripts/nx-release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { URL } from 'node:url';
import { isRelativeVersionKeyword } from 'nx/src/command-line/release/utils/semver';
import { ReleaseType, inc, major, parse } from 'semver';
import * as yargs from 'yargs';
import * as chalk from 'chalk';

const LARGE_BUFFER = 1024 * 1000000;

Expand Down Expand Up @@ -119,7 +120,7 @@ const LARGE_BUFFER = 1024 * 1000000;
// If publishing locally, force all projects to not be private first
if (options.local) {
console.log(
'\nPublishing locally, so setting all packages with existing nx-release-publish targets to not be private. If you have created a new private package and you want it to be published, you will need to manually configure the "nx-release-publish" target using executor "@nx/js:release-publish"'
chalk.dim`\n Publishing locally, so setting all packages with existing nx-release-publish targets to not be private. If you have created a new private package and you want it to be published, you will need to manually configure the "nx-release-publish" target using executor "@nx/js:release-publish"`
);
const projectGraph = await createProjectGraphAsync();
for (const proj of Object.values(projectGraph.nodes)) {
Expand Down Expand Up @@ -160,6 +161,20 @@ const LARGE_BUFFER = 1024 * 1000000;
});
}

let version;
if (['minor', 'major', 'patch'].includes(options.version)) {
const currentLatestVersion = execSync('npm view nx@latest version')
.toString()
.trim();

version = inc(currentLatestVersion, options.version, undefined);
} else {
version = options.version;
}

console.log(chalk.green` > Published version: ` + version);
console.log(chalk.dim` Use: npx create-nx-workspace@${version}\n`);

process.exit(0);
})();

Expand Down

0 comments on commit c2fb4ac

Please sign in to comment.