Skip to content

Commit

Permalink
Actually fix node_modules in mocha tests, fix custom-outputpaths test
Browse files Browse the repository at this point in the history
  • Loading branch information
xg-wang committed Aug 22, 2021
1 parent 8c75a4e commit 032b7c7
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 48 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,4 @@ jobs:
yarn install --ignore-engines --frozen-lockfile
- name: Run Mocha Tests
run: |
node scripts/fix-node-modules.mjs
yarn workspace ember-cli-fastboot test:mocha
4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"test-packages/*"
],
"scripts": {
"pretest": "node scripts/fix-node-modules.mjs",
"test": "npm-run-all test:*",
"test:ember-cli-fastboot": "yarn workspace ember-cli-fastboot test:ember",
"test:fastboot": "yarn workspace fastboot test",
Expand All @@ -20,9 +19,6 @@
"test:extra": "yarn workspace basic-app test:mocha && yarn workspace custom-fastboot-app test:mocha"
},
"devDependencies": {
"chalk": "^4.1.2",
"execa": "^5.1.1",
"fs-extra": "^10.0.0",
"npm-run-all": "^4.1.5",
"release-it": "^14.2.2",
"release-it-lerna-changelog": "^3.1.0",
Expand Down
47 changes: 47 additions & 0 deletions packages/ember-cli-fastboot/fix-node-modules.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* Fix nested packages not using workspace version
* ember-cli-addon-tests will link ember-cli-fastboot and run npm install in the test apps,
* the installation will install fastboot from npm registry rather than workspace version
*
*/

import path from 'path';
import fs from 'fs-extra';
import { fileURLToPath } from 'url';
import chalk from 'chalk';
const __dirname = path.dirname(fileURLToPath(import.meta.url));

const packagesDir = path.resolve(__dirname, '../../packages');
const nodeModulesDir = path.resolve(__dirname, 'node_modules');

// eslint-disable-next-line no-undef
const shouldRestore = process.argv[2];
if (shouldRestore === '--help' || shouldRestore === '-h') {
console.log(`Usage: node fix-node-modules.mjs [arguments]
Options:
-h, --help print this message
-r, --restore restore node_modules by removing symlinks`);
} else if (shouldRestore === '-r' || shouldRestore === '--restore') {
run(true);
} else {
run(false);
}

function run(shouldRestore) {
['fastboot', 'fastboot-express-middleware'].forEach((packageName) => {
const nodeModulesPackageDir = path.join(nodeModulesDir, packageName);
const workspacesPackageDir = path.resolve(packagesDir, packageName);
if (fs.existsSync(nodeModulesPackageDir)) {
console.log(chalk.blue(`remove ${nodeModulesPackageDir}`));
fs.removeSync(nodeModulesPackageDir);
}
if (!shouldRestore) {
console.log(
chalk.green(
`symlink ${nodeModulesPackageDir} -> ${workspacesPackageDir}`
)
);
fs.symlinkSync(workspacesPackageDir, nodeModulesPackageDir, 'dir');
}
});
}
6 changes: 3 additions & 3 deletions packages/ember-cli-fastboot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"lint:js:fix": "eslint . --fix",
"start": "ember serve",
"test": "npm-run-all lint test:*",
"test:mocha": "mocha",
"test:mocha": "node fix-node-modules.mjs && mocha && node fix-node-modules.mjs -r",
"test:ember": "ember test",
"test:precook": "node node_modules/ember-cli-addon-tests/scripts/precook-node-modules.js"
},
Expand All @@ -34,7 +34,7 @@
"broccoli-merge-trees": "^3.0.1",
"broccoli-plugin": "^1.3.1",
"broccoli-persistent-filter": "^3.1.2",
"chalk": "^2.4.1",
"chalk": "^4.1.2",
"ember-cli-babel": "^7.26.3",
"ember-cli-htmlbars": "^5.7.1",
"ember-cli-lodash-subset": "2.0.1",
Expand All @@ -43,7 +43,7 @@
"fastboot": "3.2.0-beta.2",
"fastboot-express-middleware": "3.2.0-beta.2",
"fastboot-transform": "^0.1.3",
"fs-extra": "^7.0.0",
"fs-extra": "^10.0.0",
"jsdom": "^16.2.2",
"json-stable-stringify": "^1.0.1",
"md5-hex": "^2.0.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Customized Output Paths</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">

{{content-for "head"}}

<link integrity="" rel="stylesheet" href="{{rootURL}}assets/vendor.css">
<link integrity="" rel="stylesheet" href="{{rootURL}}some-assets/pth/app.css">

{{content-for "head-footer"}}
</head>
<body>
{{content-for "body"}}

<script src="{{rootURL}}some-assets/path/lib.js"></script>
<script src="{{rootURL}}some-assets/path/app-file.js"></script>

{{content-for "body-footer"}}
</body>
</html>

39 changes: 0 additions & 39 deletions scripts/fix-node-modules.mjs

This file was deleted.

2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9650,7 +9650,7 @@ execa@^4.0.2, execa@^4.0.3:
signal-exit "^3.0.2"
strip-final-newline "^2.0.0"

execa@^5.0.0, execa@^5.1.1:
execa@^5.0.0:
version "5.1.1"
resolved "https://registry.yarnpkg.com/execa/-/execa-5.1.1.tgz#f80ad9cbf4298f7bd1d4c9555c21e93741c411dd"
integrity sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==
Expand Down

0 comments on commit 032b7c7

Please sign in to comment.