Skip to content

Commit 032b7c7

Browse files
committed
Actually fix node_modules in mocha tests, fix custom-outputpaths test
1 parent 8c75a4e commit 032b7c7

File tree

7 files changed

+77
-48
lines changed

7 files changed

+77
-48
lines changed

.github/workflows/ci.yml

-1
Original file line numberDiff line numberDiff line change
@@ -114,5 +114,4 @@ jobs:
114114
yarn install --ignore-engines --frozen-lockfile
115115
- name: Run Mocha Tests
116116
run: |
117-
node scripts/fix-node-modules.mjs
118117
yarn workspace ember-cli-fastboot test:mocha

package.json

-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"test-packages/*"
1111
],
1212
"scripts": {
13-
"pretest": "node scripts/fix-node-modules.mjs",
1413
"test": "npm-run-all test:*",
1514
"test:ember-cli-fastboot": "yarn workspace ember-cli-fastboot test:ember",
1615
"test:fastboot": "yarn workspace fastboot test",
@@ -20,9 +19,6 @@
2019
"test:extra": "yarn workspace basic-app test:mocha && yarn workspace custom-fastboot-app test:mocha"
2120
},
2221
"devDependencies": {
23-
"chalk": "^4.1.2",
24-
"execa": "^5.1.1",
25-
"fs-extra": "^10.0.0",
2622
"npm-run-all": "^4.1.5",
2723
"release-it": "^14.2.2",
2824
"release-it-lerna-changelog": "^3.1.0",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* Fix nested packages not using workspace version
3+
* ember-cli-addon-tests will link ember-cli-fastboot and run npm install in the test apps,
4+
* the installation will install fastboot from npm registry rather than workspace version
5+
*
6+
*/
7+
8+
import path from 'path';
9+
import fs from 'fs-extra';
10+
import { fileURLToPath } from 'url';
11+
import chalk from 'chalk';
12+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
13+
14+
const packagesDir = path.resolve(__dirname, '../../packages');
15+
const nodeModulesDir = path.resolve(__dirname, 'node_modules');
16+
17+
// eslint-disable-next-line no-undef
18+
const shouldRestore = process.argv[2];
19+
if (shouldRestore === '--help' || shouldRestore === '-h') {
20+
console.log(`Usage: node fix-node-modules.mjs [arguments]
21+
Options:
22+
-h, --help print this message
23+
-r, --restore restore node_modules by removing symlinks`);
24+
} else if (shouldRestore === '-r' || shouldRestore === '--restore') {
25+
run(true);
26+
} else {
27+
run(false);
28+
}
29+
30+
function run(shouldRestore) {
31+
['fastboot', 'fastboot-express-middleware'].forEach((packageName) => {
32+
const nodeModulesPackageDir = path.join(nodeModulesDir, packageName);
33+
const workspacesPackageDir = path.resolve(packagesDir, packageName);
34+
if (fs.existsSync(nodeModulesPackageDir)) {
35+
console.log(chalk.blue(`remove ${nodeModulesPackageDir}`));
36+
fs.removeSync(nodeModulesPackageDir);
37+
}
38+
if (!shouldRestore) {
39+
console.log(
40+
chalk.green(
41+
`symlink ${nodeModulesPackageDir} -> ${workspacesPackageDir}`
42+
)
43+
);
44+
fs.symlinkSync(workspacesPackageDir, nodeModulesPackageDir, 'dir');
45+
}
46+
});
47+
}

packages/ember-cli-fastboot/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"lint:js:fix": "eslint . --fix",
2424
"start": "ember serve",
2525
"test": "npm-run-all lint test:*",
26-
"test:mocha": "mocha",
26+
"test:mocha": "node fix-node-modules.mjs && mocha && node fix-node-modules.mjs -r",
2727
"test:ember": "ember test",
2828
"test:precook": "node node_modules/ember-cli-addon-tests/scripts/precook-node-modules.js"
2929
},
@@ -34,7 +34,7 @@
3434
"broccoli-merge-trees": "^3.0.1",
3535
"broccoli-plugin": "^1.3.1",
3636
"broccoli-persistent-filter": "^3.1.2",
37-
"chalk": "^2.4.1",
37+
"chalk": "^4.1.2",
3838
"ember-cli-babel": "^7.26.3",
3939
"ember-cli-htmlbars": "^5.7.1",
4040
"ember-cli-lodash-subset": "2.0.1",
@@ -43,7 +43,7 @@
4343
"fastboot": "3.2.0-beta.2",
4444
"fastboot-express-middleware": "3.2.0-beta.2",
4545
"fastboot-transform": "^0.1.3",
46-
"fs-extra": "^7.0.0",
46+
"fs-extra": "^10.0.0",
4747
"jsdom": "^16.2.2",
4848
"json-stable-stringify": "^1.0.1",
4949
"md5-hex": "^2.0.0",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<title>Customized Output Paths</title>
7+
<meta name="description" content="">
8+
<meta name="viewport" content="width=device-width, initial-scale=1">
9+
10+
{{content-for "head"}}
11+
12+
<link integrity="" rel="stylesheet" href="{{rootURL}}assets/vendor.css">
13+
<link integrity="" rel="stylesheet" href="{{rootURL}}some-assets/pth/app.css">
14+
15+
{{content-for "head-footer"}}
16+
</head>
17+
<body>
18+
{{content-for "body"}}
19+
20+
<script src="{{rootURL}}some-assets/path/lib.js"></script>
21+
<script src="{{rootURL}}some-assets/path/app-file.js"></script>
22+
23+
{{content-for "body-footer"}}
24+
</body>
25+
</html>
26+

scripts/fix-node-modules.mjs

-39
This file was deleted.

yarn.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -9650,7 +9650,7 @@ execa@^4.0.2, execa@^4.0.3:
96509650
signal-exit "^3.0.2"
96519651
strip-final-newline "^2.0.0"
96529652

9653-
execa@^5.0.0, execa@^5.1.1:
9653+
execa@^5.0.0:
96549654
version "5.1.1"
96559655
resolved "https://registry.yarnpkg.com/execa/-/execa-5.1.1.tgz#f80ad9cbf4298f7bd1d4c9555c21e93741c411dd"
96569656
integrity sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==

0 commit comments

Comments
 (0)