Skip to content

Commit

Permalink
feat: modify package json before publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
BioPhoton committed Sep 30, 2024
1 parent afaeb5f commit 3faf91c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
20 changes: 20 additions & 0 deletions projects/nx-verdaccio/src/executors/pkg-publish/pkg-version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { join } from 'node:path';
import { readFile } from '@nx/plugin/testing';
import type { PackageJson } from 'nx/src/utils/package-json';
import { writeFile } from 'node:fs/promises';

export async function postfixVersion(dist: string): Promise<void> {
const pkgPath = join(process.cwd(), dist, 'package.json');
const pkg = JSON.parse(await readFile(pkgPath)) as PackageJson;
return writeFile(
pkgPath,
JSON.stringify(
{
...pkg,
version: `${pkg.version}-e2e`,
},
null,
2
)
);
}
15 changes: 7 additions & 8 deletions projects/nx-verdaccio/src/plugin/targets/environment.targets.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ProjectConfiguration, TargetConfiguration } from '@nx/devkit';
import type { NormalizedCreateNodeOptions } from '../normalize-create-nodes-options';
import { join } from 'node:path';
import { TARGET_PACKAGE_NPM_INSTALL } from './package.targets';
import { TARGET_PACKAGE_INSTALL } from './package.targets';
import type { BuildEnvEnvironmentsOptions } from '../schema';
import type { StartVerdaccioOptions } from '../../executors/env-bootstrap/verdaccio-registry';
import { uniquePort } from '../../executors/env-bootstrap/unique-port';
Expand All @@ -12,14 +12,13 @@ import {
import { PACKAGE_NAME } from '../constants';
import { EXECUTOR_ENVIRONMENT_KILL_PROCESS } from '../../executors/kill-process/constant';
import { EXECUTOR_ENVIRONMENT_SETUP } from '../../executors/env-setup/constants';
import * as constants from 'constants';
import { iterateEntries } from '../../internal/transform';

export const TARGET_ENVIRONMENT_VERDACCIO_START = 'pb-ve-env-verdaccio-start';
export const TARGET_ENVIRONMENT_BOOTSTRAP = 'pb-ve-env-bootstrap';
export const TARGET_ENVIRONMENT_INSTALL = 'pb-ve-env-install';
export const TARGET_ENVIRONMENT_SETUP = 'pb-ve-env-setup';
export const TARGET_ENVIRONMENT_VERDACCIO_STOP = 'pb-ve-env-verdaccio-stop';
export const TARGET_ENVIRONMENT_VERDACCIO_START = 'nxv-env-verdaccio-start';
export const TARGET_ENVIRONMENT_BOOTSTRAP = 'nxv-env-bootstrap';
export const TARGET_ENVIRONMENT_INSTALL = 'nxv-env-install';
export const TARGET_ENVIRONMENT_SETUP = 'nxv-env-setup';
export const TARGET_ENVIRONMENT_VERDACCIO_STOP = 'nxv-env-verdaccio-stop';

export function isEnvProject(
projectConfig: ProjectConfiguration,
Expand Down Expand Up @@ -106,7 +105,7 @@ export function getEnvTargets(
dependsOn: [
{
projects: 'dependencies',
target: TARGET_PACKAGE_NPM_INSTALL,
target: TARGET_PACKAGE_INSTALL,
params: 'forward',
},
],
Expand Down

0 comments on commit 3faf91c

Please sign in to comment.