Skip to content

Commit

Permalink
Merge branch 'master' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacplmann committed Apr 29, 2024
2 parents 4a8acfd + 9c6532c commit bf0f60a
Show file tree
Hide file tree
Showing 10 changed files with 662 additions and 115 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Expand Up @@ -192,7 +192,7 @@ jobs:
env
whoami
sudo pkg install -y -f node libnghttp2 npm git
sudo npm install --location=global --ignore-scripts pnpm
sudo npm install --location=global --ignore-scripts pnpm@8.15.7
curl https://sh.rustup.rs -sSf --output rustup.sh
sh rustup.sh -y --profile minimal --default-toolchain stable
source "$HOME/.cargo/env"
Expand Down
2 changes: 1 addition & 1 deletion nx-dev/ui-fence/src/lib/fences/terminal-output.tsx
Expand Up @@ -17,7 +17,7 @@ export function TerminalOutput({
<div className="items-left flex flex-col">
{commandLines.map((line, index) => {
return (
<div key={index} className="flex items-center">
<div key={index} className="flex">
<p className="mt-0.5">
{path && (
<span className="text-purple-600 dark:text-fuchsia-500">
Expand Down
58 changes: 41 additions & 17 deletions packages/js/src/executors/verdaccio/verdaccio.impl.ts
Expand Up @@ -9,6 +9,11 @@ import { major } from 'semver';

let childProcess: ChildProcess;

let env: NodeJS.ProcessEnv = {
SKIP_YARN_COREPACK_CHECK: 'true',
...process.env,
};

/**
* - set npm and yarn to use local registry
* - start verdaccio
Expand Down Expand Up @@ -126,24 +131,27 @@ function createVerdaccioOptions(

function setupNpm(options: VerdaccioExecutorSchema) {
try {
execSync('npm --version');
execSync('npm --version', { env });
} catch (e) {
return () => {};
}

let npmRegistryPath: string;
try {
npmRegistryPath = execSync(
`npm config get registry --location ${options.location}`
`npm config get registry --location ${options.location}`,
{ env }
)
?.toString()
?.trim()
?.replace('\u001b[2K\u001b[1G', ''); // strip out ansi codes
execSync(
`npm config set registry http://localhost:${options.port}/ --location ${options.location}`
`npm config set registry http://localhost:${options.port}/ --location ${options.location}`,
{ env }
);
execSync(
`npm config set //localhost:${options.port}/:_authToken="secretVerdaccioToken" --location ${options.location}`
`npm config set //localhost:${options.port}/:_authToken="secretVerdaccioToken" --location ${options.location}`,
{ env }
);
logger.info(`Set npm registry to http://localhost:${options.port}/`);
} catch (e) {
Expand All @@ -155,22 +163,27 @@ function setupNpm(options: VerdaccioExecutorSchema) {
return () => {
try {
const currentNpmRegistryPath = execSync(
`npm config get registry --location ${options.location}`
`npm config get registry --location ${options.location}`,
{ env }
)
?.toString()
?.trim()
?.replace('\u001b[2K\u001b[1G', ''); // strip out ansi codes
if (npmRegistryPath && currentNpmRegistryPath.includes('localhost')) {
execSync(
`npm config set registry ${npmRegistryPath} --location ${options.location}`
`npm config set registry ${npmRegistryPath} --location ${options.location}`,
{ env }
);
logger.info(`Reset npm registry to ${npmRegistryPath}`);
} else {
execSync(`npm config delete registry --location ${options.location}`);
execSync(`npm config delete registry --location ${options.location}`, {
env,
});
logger.info('Cleared custom npm registry');
}
execSync(
`npm config delete //localhost:${options.port}/:_authToken --location ${options.location}`
`npm config delete //localhost:${options.port}/:_authToken --location ${options.location}`,
{ env }
);
} catch (e) {
throw new Error(`Failed to reset npm registry: ${e.message}`);
Expand All @@ -182,7 +195,9 @@ function getYarnUnsafeHttpWhitelist(isYarnV1: boolean) {
return !isYarnV1
? new Set<string>(
JSON.parse(
execSync(`yarn config get unsafeHttpWhitelist --json`).toString()
execSync(`yarn config get unsafeHttpWhitelist --json`, {
env,
}).toString()
)
)
: null;
Expand All @@ -196,12 +211,14 @@ function setYarnUnsafeHttpWhitelist(
execSync(
`yarn config set unsafeHttpWhitelist --json '${JSON.stringify(
Array.from(currentWhitelist)
)}'` + (options.location === 'user' ? ' --home' : '')
)}'` + (options.location === 'user' ? ' --home' : ''),
{ env }
);
} else {
execSync(
`yarn config unset unsafeHttpWhitelist` +
(options.location === 'user' ? ' --home' : '')
(options.location === 'user' ? ' --home' : ''),
{ env }
);
}
}
Expand All @@ -210,22 +227,26 @@ function setupYarn(options: VerdaccioExecutorSchema) {
let isYarnV1;

try {
isYarnV1 = major(execSync('yarn --version').toString().trim()) === 1;
isYarnV1 =
major(execSync('yarn --version', { env }).toString().trim()) === 1;
} catch {
// This would fail if yarn is not installed which is okay
return () => {};
}
try {
const registryConfigName = isYarnV1 ? 'registry' : 'npmRegistryServer';

const yarnRegistryPath = execSync(`yarn config get ${registryConfigName}`)
const yarnRegistryPath = execSync(`yarn config get ${registryConfigName}`, {
env,
})
?.toString()
?.trim()
?.replace('\u001b[2K\u001b[1G', ''); // strip out ansi codes

execSync(
`yarn config set ${registryConfigName} http://localhost:${options.port}/` +
(options.location === 'user' ? ' --home' : '')
(options.location === 'user' ? ' --home' : ''),
{ env }
);

logger.info(`Set yarn registry to http://localhost:${options.port}/`);
Expand All @@ -248,15 +269,17 @@ function setupYarn(options: VerdaccioExecutorSchema) {
return () => {
try {
const currentYarnRegistryPath = execSync(
`yarn config get ${registryConfigName}`
`yarn config get ${registryConfigName}`,
{ env }
)
?.toString()
?.trim()
?.replace('\u001b[2K\u001b[1G', ''); // strip out ansi codes
if (yarnRegistryPath && currentYarnRegistryPath.includes('localhost')) {
execSync(
`yarn config set ${registryConfigName} ${yarnRegistryPath}` +
(options.location === 'user' ? ' --home' : '')
(options.location === 'user' ? ' --home' : ''),
{ env }
);
logger.info(
`Reset yarn ${registryConfigName} to ${yarnRegistryPath}`
Expand All @@ -266,7 +289,8 @@ function setupYarn(options: VerdaccioExecutorSchema) {
`yarn config ${
isYarnV1 ? 'delete' : 'unset'
} ${registryConfigName}` +
(options.location === 'user' ? ' --home' : '')
(options.location === 'user' ? ' --home' : ''),
{ env }
);
logger.info(`Cleared custom yarn ${registryConfigName}`);
}
Expand Down
14 changes: 13 additions & 1 deletion packages/nx/src/native/pseudo_terminal/pseudo_terminal.rs
Expand Up @@ -82,7 +82,12 @@ pub fn create_pseudo_terminal() -> napi::Result<PseudoTerminal> {
let quiet = quiet_clone.load(Ordering::Relaxed);
trace!("Quiet: {}", quiet);
if !quiet {
if stdout.write_all(&buf[0..len]).is_err() {
let mut content = String::from_utf8_lossy(&buf[0..len]).to_string();
if content.contains("\x1B[6n") {
trace!("Prevented terminal escape sequence ESC[6n from being printed.");
content = content.replace("\x1B[6n", "");
}
if stdout.write_all(content.as_bytes()).is_err() {
break;
} else {
let _ = stdout.flush();
Expand Down Expand Up @@ -144,8 +149,12 @@ pub fn run_command(
}
let process_killer = child.clone_killer();

trace!("Getting running clone");
let running_clone = pseudo_terminal.running.clone();
trace!("Getting printing_rx clone");
let printing_rx = pseudo_terminal.printing_rx.clone();

trace!("spawning thread to wait for command");
std::thread::spawn(move || {
trace!("Waiting for {}", command);

Expand Down Expand Up @@ -173,9 +182,12 @@ pub fn run_command(
disable_raw_mode().expect("Failed to restore non-raw terminal");
}
exit_to_process_tx.send(exit.to_string()).ok();
} else {
trace!("Error waiting for {}", command);
};
});

trace!("Returning ChildProcess");
Ok(ChildProcess::new(
process_killer,
pseudo_terminal.message_rx.clone(),
Expand Down
@@ -0,0 +1,47 @@
export default `hoistPattern:
- '*'
hoistedDependencies:
/ansi-regex/5.0.1:
ansi-regex: private
/ansi-styles/4.3.0:
ansi-styles: private
/color-convert/2.0.1:
color-convert: private
/color-name/1.1.4:
color-name: private
/eastasianwidth/0.2.0:
eastasianwidth: private
/emoji-regex/8.0.0:
emoji-regex: private
/is-fullwidth-code-point/3.0.0:
is-fullwidth-code-point: private
/string-width/4.2.3:
string-width-cjs: private
/string-width/5.1.2:
string-width: private
/strip-ansi/6.0.1:
strip-ansi-cjs: private
/strip-ansi/7.1.0:
strip-ansi: private
/wrap-ansi/7.0.0:
wrap-ansi-cjs: private
/wrap-ansi/8.1.0:
wrap-ansi: private
included:
dependencies: true
devDependencies: true
optionalDependencies: true
injectedDeps: {}
layoutVersion: 5
nodeLinker: isolated
packageManager: pnpm@8.15.7
pendingBuilds: []
prunedAt: Fri, 26 Apr 2024 15:10:54 GMT
publicHoistPattern:
- '*eslint*'
- '*prettier*'
registries:
default: https://registry.npmjs.org/
skipped: []
storeDir: /Users/jdoe/Library/pnpm/store/v3
virtualStoreDir: .pnpm`;

0 comments on commit bf0f60a

Please sign in to comment.