Skip to content

Commit

Permalink
Fix misnomer: remove misleading references to npm because npm is not …
Browse files Browse the repository at this point in the history
…actually being used
  • Loading branch information
cspotcode committed Nov 25, 2020
1 parent f37f2ba commit 3007429
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 53 deletions.
12 changes: 5 additions & 7 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ jobs:
run: yarn deduplicate:check

test:
name: Test on Node ${{ matrix.node }} and ${{ matrix.os }} using ${{ matrix.package_manager }}
name: Test on Node ${{ matrix.node }} and ${{ matrix.os }}, yarn2?:${{ matrix.should_use_yarn2 }}

runs-on: ${{ matrix.os }}
strategy:
matrix:
node: ['10.x', '12.x', '14.x']
os: [ubuntu-latest, windows-latest, macOS-latest]
package_manager: [npm, yarn2]
should_use_yarn2: [false, true]

steps:
- name: Checkout repo
Expand All @@ -49,7 +49,7 @@ jobs:
uses: bahmutov/npm-install@v1

- name: Restore yarn2 cache
if: ${{ matrix.package_manager == 'yarn2' }}
if: ${{ matrix.should_use_yarn2 }}
uses: actions/cache@v2
with:
path: |
Expand All @@ -58,12 +58,10 @@ jobs:
key: cache-key

- name: Prepare yarn2 cache and seed lockfile
if: ${{ matrix.package_manager == 'yarn2' }}
if: ${{ matrix.should_use_yarn2 }}
run: cd test/yarn2 && touch yarn.lock && yarn
env:
TSDX_TEST_PACKAGE_MANAGER: ${{ matrix.package_manager }}

- name: Test package
run: yarn test:post-build
env:
TSDX_TEST_PACKAGE_MANAGER: ${{ matrix.package_manager }}
SHOULD_USE_YARN2: ${{ matrix.should_use_yarn2 }}
12 changes: 6 additions & 6 deletions scripts/rebuild-and-test-with-yarn2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ yarn
popd

# Run tests
TSDX_TEST_PACKAGE_MANAGER=yarn2 yarn test:post-build
SHOULD_USE_YARN2=true yarn test:post-build

##############################

Expand All @@ -43,10 +43,10 @@ TSDX_TEST_PACKAGE_MANAGER=yarn2 yarn test:post-build
# fi
# done

# TSDX_TEST_PACKAGE_MANAGER=yarn2 yarn test:post-build ./test/e2e/tsdx-build-default.test.ts
# TSDX_TEST_PACKAGE_MANAGER=yarn2 yarn test:post-build ./test/e2e/tsdx-build-withTsconfig.test
# TSDX_TEST_PACKAGE_MANAGER=yarn2 yarn test:post-build ./test/integration/tsdx-build-withConfig.test
# SHOULD_USE_YARN2=true yarn test:post-build ./test/e2e/tsdx-build-default.test.ts
# SHOULD_USE_YARN2=true yarn test:post-build ./test/e2e/tsdx-build-withTsconfig.test
# SHOULD_USE_YARN2=true yarn test:post-build ./test/integration/tsdx-build-withConfig.test
# for file in ./test/**/*.test.ts ; do
# TSDX_TEST_PACKAGE_MANAGER=yarn2 yarn test:post-build "$file"
# SHOULD_USE_YARN2=true yarn test:post-build "$file"
# done
# TSDX_TEST_PACKAGE_MANAGER=yarn2 yarn test:post-build --maxWorkers=1
# SHOULD_USE_YARN2=true yarn test:post-build --maxWorkers=1
44 changes: 20 additions & 24 deletions test/utils/fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ import * as os from 'os';
import * as libTester from './lib-tester';

export const rootDir = process.cwd();
export const stageRootDir =
getPackageManager() === 'yarn2'
? path.join(os.tmpdir(), 'tsdx-test-stages')
: rootDir;
export const tsdxBin =
getPackageManager() === 'yarn2'
? 'yarn tsdx'
: `node ${rootDir}/dist/index.js`;
export const stageRootDir = isYarn2()
? path.join(os.tmpdir(), 'tsdx-test-stages')
: rootDir;
export const tsdxBin = isYarn2()
? 'yarn tsdx'
: `node ${rootDir}/dist/index.js`;

shell.config.silent = true;

Expand All @@ -26,15 +24,15 @@ export function setupStageWithFixture(
shell.exec(
`cp -a ${rootDir}/test/${testDir}/fixtures/${fixtureName}/. ${stagePath}/`
);
if (getPackageManager() === 'npm') {
if (!isYarn2()) {
shell.ln(
'-s',
path.join(rootDir, 'node_modules'),
path.join(stagePath, 'node_modules')
);
}
shell.cd(stagePath);
if (getPackageManager() === 'yarn2') {
if (isYarn2()) {
// Setup stage directory as a project root for yarn2
fs.writeFileSync(
'.yarnrc.yml',
Expand All @@ -50,25 +48,24 @@ export function setupStageWithFixture(
}

export function packageManagerInstall() {
if (getPackageManager() === 'yarn2') {
// Add tsdx dependency pointed to project directory
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
pkg.dependencies = pkg.dependencies ?? {};
pkg.dependencies['tsdx'] = `portal:${rootDir}`;
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2));
const { code } = shell.exec(`yarn`);
if (code !== 0) throw new Error('yarn install failed');
}
if (!isYarn2()) return;

// Add tsdx dependency pointed to project directory
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
pkg.dependencies = pkg.dependencies ?? {};
pkg.dependencies['tsdx'] = `portal:${rootDir}`;
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2));
const { code } = shell.exec(`yarn`);
if (code !== 0) throw new Error('yarn install failed');
}

export function teardownStage(stageName: string): void {
shell.cd(rootDir);
shell.rm('-rf', getStagePath(stageName));
}

export function getPackageManager() {
if (process.env.TSDX_TEST_PACKAGE_MANAGER === 'yarn2') return 'yarn2';
return 'npm';
export function isYarn2() {
return process.env.SHOULD_USE_YARN2 === 'true';
}

export function getStagePath(stageName: string) {
Expand All @@ -78,11 +75,10 @@ export function getStagePath(stageName: string) {
export function getLibTester(libPath: string) {
const absLibPath = path.resolve(libPath);
function evaluate(expression: string): any {
const isYarn2 = getPackageManager() === 'yarn2';
const libTesterPath = require.resolve('./lib-tester.js');
const args: libTester.JsonArgs = { libPath: absLibPath, expression };
const encodedValue = shell.exec(
`${isYarn2 ? 'yarn ' : ''}node ${libTesterPath} ${Buffer.from(
`${isYarn2() ? 'yarn ' : ''}node ${libTesterPath} ${Buffer.from(
JSON.stringify(args)
).toString('base64')}`
);
Expand Down
32 changes: 16 additions & 16 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,10 @@
chalk "^2.0.0"
js-tokens "^4.0.0"

"@babel/parser@^7.0.0", "@babel/parser@^7.1.0", "@babel/parser@^7.10.4", "@babel/parser@^7.11.5", "@babel/parser@^7.7.5", "@babel/parser@^7.9.0":
version "7.11.5"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.11.5.tgz#c7ff6303df71080ec7a4f5b8c003c58f1cf51037"
integrity sha512-X9rD8qqm695vgmeaQ4fvz/o3+Wk4ZzQvSHkDBgpYKxpD4qTAUm88ZKtHkVqIOsYFFbIQ6wQYhC6q7pjqVK0E0Q==
"@babel/parser@^7.0.0", "@babel/parser@^7.1.0", "@babel/parser@^7.10.4", "@babel/parser@^7.11.5", "@babel/parser@^7.12.7", "@babel/parser@^7.7.5", "@babel/parser@^7.9.0":
version "7.12.7"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.12.7.tgz#fee7b39fe809d0e73e5b25eecaf5780ef3d73056"
integrity sha512-oWR02Ubp4xTLCAqPRiNIuMVgNO5Aif/xpXtabhzW2HWUD47XJsAB4Zd/Rg30+XeQA3juXigV7hlquOTmwqLiwg==

"@babel/plugin-proposal-async-generator-functions@^7.10.4":
version "7.10.5"
Expand Down Expand Up @@ -825,13 +825,13 @@
regenerator-runtime "^0.13.4"

"@babel/template@^7.10.4", "@babel/template@^7.3.3", "@babel/template@^7.7.4", "@babel/template@^7.8.3", "@babel/template@^7.8.6":
version "7.10.4"
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.10.4.tgz#3251996c4200ebc71d1a8fc405fba940f36ba278"
integrity sha512-ZCjD27cGJFUB6nmCB1Enki3r+L5kJveX9pq1SvAUKoICy6CZ9yD8xO086YXdYhvNjBdnekm4ZnaP5yC8Cs/1tA==
version "7.12.7"
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.12.7.tgz#c817233696018e39fbb6c491d2fb684e05ed43bc"
integrity sha512-GkDzmHS6GV7ZeXfJZ0tLRBhZcMcY0/Lnb+eEbXDBfCAcZCjrZKe6p3J4we/D24O9Y8enxWAg1cWwof59yLh2ow==
dependencies:
"@babel/code-frame" "^7.10.4"
"@babel/parser" "^7.10.4"
"@babel/types" "^7.10.4"
"@babel/parser" "^7.12.7"
"@babel/types" "^7.12.7"

"@babel/traverse@^7.0.0", "@babel/traverse@^7.1.0", "@babel/traverse@^7.10.4", "@babel/traverse@^7.11.5", "@babel/traverse@^7.4.5", "@babel/traverse@^7.7.4", "@babel/traverse@^7.9.0":
version "7.11.5"
Expand All @@ -848,10 +848,10 @@
globals "^11.1.0"
lodash "^4.17.19"

"@babel/types@^7.0.0", "@babel/types@^7.10.4", "@babel/types@^7.10.5", "@babel/types@^7.11.0", "@babel/types@^7.11.5", "@babel/types@^7.3.0", "@babel/types@^7.3.3", "@babel/types@^7.4.4", "@babel/types@^7.9.0":
version "7.12.6"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.12.6.tgz#ae0e55ef1cce1fbc881cd26f8234eb3e657edc96"
integrity sha512-hwyjw6GvjBLiyy3W0YQf0Z5Zf4NpYejUnKFcfcUhZCSffoBBp30w6wP2Wn6pk31jMYZvcOrB/1b7cGXvEoKogA==
"@babel/types@^7.0.0", "@babel/types@^7.10.4", "@babel/types@^7.10.5", "@babel/types@^7.11.0", "@babel/types@^7.11.5", "@babel/types@^7.12.7", "@babel/types@^7.3.0", "@babel/types@^7.3.3", "@babel/types@^7.4.4", "@babel/types@^7.9.0":
version "7.12.7"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.12.7.tgz#6039ff1e242640a29452c9ae572162ec9a8f5d13"
integrity sha512-MNyI92qZq6jrQkXvtIiykvl4WtoRrVV9MPn+ZfsoEENjiWcBQ3ZSHrkxnJWgWtLX3XXqX5hrSQ+X69wkmesXuQ==
dependencies:
"@babel/helper-validator-identifier" "^7.10.4"
lodash "^4.17.19"
Expand Down Expand Up @@ -2586,9 +2586,9 @@ cosmiconfig@^6.0.0:
yaml "^1.7.2"

create-require@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.0.2.tgz#03f97ad0822826e506965f385fd90388f5051624"
integrity sha512-ZizhnQtkxsH1XNsnRy8z2SHRTDAem7fmEJbw1oeuTEkgf5sLXtjrm4nhDcYkO0aiZnAk5dwAze65EvTRaOvxZw==
version "1.1.0"
resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.0.tgz#8fe85b319928953deef6f0e5c44bfea13e3c81ef"
integrity sha512-yEFVS7dQjDXp5iOEtWisN4uFmL+pUTyIaEizKda9Eb77XX58p6pgFOLAPaBCP+IR6ZPZ1jgJLAuf+ABk0zXYBQ==

cross-spawn@^6.0.0, cross-spawn@^6.0.5:
version "6.0.5"
Expand Down

0 comments on commit 3007429

Please sign in to comment.