Skip to content

Commit

Permalink
refactor: use nxp execution with windows hide & explicit npm install …
Browse files Browse the repository at this point in the history
…include
  • Loading branch information
BioPhoton authored Oct 22, 2024
2 parents a4d9d9b + 1ec3e38 commit 36728a0
Show file tree
Hide file tree
Showing 29 changed files with 311 additions and 90 deletions.
22 changes: 21 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,26 @@ jobs:
- name: Audit production dependencies
run: npm audit --omit=dev --omit=optional

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: npm
- name: Set base and head for Nx affected commands
uses: nrwl/nx-set-shas@v4
- name: Install dependencies
run: npm ci
- name: Lint affected projects
run: npx nx affected -t lint --parallel=3 --verbose

unit-test:
strategy:
fail-fast: false
Expand Down Expand Up @@ -70,4 +90,4 @@ jobs:
- name: Install dependencies
run: npm i
- name: E2E test affected projects
run: npx nx affected -t nxv-e2e --exclude="tag:type:example"
run: NX_DAEMON=false; npx nx affected -t nxv-e2e --exclude="tag:type:example" --skipNxCache --verbose
8 changes: 4 additions & 4 deletions examples/e2e/cli-e2e-original/setup/global-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ export async function setup() {

// package publish all projects
await executeProcess({
command: 'nx',
command: 'npx',
args: objectToCliArgs({
_: ['run-many'],
_: ['nx', 'run-many'],
targets: 'original-npm-publish',
exclude: 'tag:type:testing',
skipNxCache: true,
Expand All @@ -44,9 +44,9 @@ export async function setup() {

// package install all projects
await executeProcess({
command: 'nx',
command: 'npx',
args: objectToCliArgs({
_: ['run-many'],
_: ['nx', 'run-many'],
targets: 'original-npm-install',
exclude: 'tag:type:testing',
skipNxCache: true,
Expand Down
5 changes: 4 additions & 1 deletion examples/e2e/cli-e2e-original/tooling/utils/npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ export async function setupNpmWorkspace(directory: string, verbose?: boolean) {
await ensureDirectoryExists(directory);
process.chdir(join(cwd, directory));
try {
execFileSync('npm', ['init', '--force']).toString();
execFileSync('npm', ['init', '--force'], {
shell: true,
windowsHide: true,
}).toString();
} catch (error) {
logError(`Error creating NPM workspace: ${(error as Error).message}`);
} finally {
Expand Down
16 changes: 11 additions & 5 deletions examples/e2e/cli-e2e-original/tooling/utils/verdaccio-npm-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { rm, writeFile } from 'node:fs/promises';
import { setupNpmWorkspace } from '../utils/npm';
import { error, info } from '../utils/logging';
import { objectToCliArgs } from '@push-based/test-utils';
import { execSync } from 'node:child_process';
import { execFileSync } from 'node:child_process';

function logInfo(msg: string) {
info(msg, 'Verdaccio Env: ');
Expand Down Expand Up @@ -95,7 +95,7 @@ export function configureRegistry(
if (verbose) {
logInfo(`Set registry:\n${setRegistry}`);
}
execSync(setRegistry);
execFileSync(setRegistry, { shell: true, windowsHide: true });

/**
* Protocol-Agnostic Configuration: The use of // allows NPM to configure authentication for a registry without tying it to a specific protocol (http: or https:).
Expand All @@ -111,7 +111,10 @@ export function configureRegistry(
if (verbose) {
logInfo(`Set authToken:\n${setAuthToken}`);
}
execSync(setAuthToken);
execFileSync(setAuthToken, {
shell: true,
windowsHide: true,
});
}

export function unconfigureRegistry(
Expand All @@ -125,13 +128,16 @@ export function unconfigureRegistry(
if (verbose) {
logInfo(`Delete authToken:\n${setAuthToken}`);
}
execSync(setAuthToken);
execFileSync(setAuthToken, {
shell: true,
windowsHide: true,
});

const setRegistry = `npm config delete registry ${objectToCliArgs({
userconfig,
}).join(' ')}`;
if (verbose) {
logInfo(`Delete registry:\n${setRegistry}`);
}
execSync(setRegistry);
execFileSync(setRegistry, { shell: true, windowsHide: true });
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,17 @@ export async function startVerdaccioServer({

return new Promise<RegistryResult>((resolve, reject) => {
executeProcess({
command: 'nx',
command: 'npx',
args: objectToCliArgs({
_: [targetName, projectName ?? '', '--'],
_: ['nx', targetName, projectName ?? '', '--'],
storage,
port,
verbose,
location,
clear,
}),
shell: true,
windowsHide: true,
observer: {
onStdout: (stdout: string, childProcess) => {
if (verbose) {
Expand Down
4 changes: 1 addition & 3 deletions examples/projects/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
"version": "0.0.1",
"dependencies": {
"@push-based/utils": "*",
"@push-based/models": "*",
"vite": "~5.0.0",
"@nx/vite": "19.8.0"
"@push-based/models": "*"
}
}
Loading

0 comments on commit 36728a0

Please sign in to comment.