Skip to content

Commit 4e66c88

Browse files
authored
Merge pull request #1430 from ember-learn/partial-build-script
implement "update prebuilt guides" script
2 parents debf3ef + c3c52c4 commit 4e66c88

File tree

5 files changed

+94
-9
lines changed

5 files changed

+94
-9
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ module.exports = {
3333
'./config/**/*.js',
3434
'./lib/*/index.js',
3535
'./server/**/*.js',
36+
'./scripts/**/*.js',
3637
],
3738
parserOptions: {
3839
sourceType: 'script',

ember-cli-build.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,25 @@
22

33
const EmberApp = require('ember-cli/lib/broccoli/ember-app');
44

5+
// All versions since this one will be built on every PR or locally
6+
// it should probably be no older than 2 LTS versions.
7+
// If you need to update older pre-built versions then you can run
8+
// npm run build:prebuilt
9+
const BUILD_SINCE = '3.24.0';
10+
11+
let guidemakerConfig = {};
12+
13+
if (!process.env.ALL_VERSIONS) {
14+
guidemakerConfig.premberVersionFilter = BUILD_SINCE;
15+
}
16+
517
module.exports = function (defaults) {
618
let app = new EmberApp(defaults, {
719
fingerprint: {
820
extensions: ['js', 'css', 'map'],
921
exclude: ['downloads'],
1022
},
11-
guidemaker: {
12-
premberVersionFilter: '3.24.0',
13-
},
23+
guidemaker: guidemakerConfig,
1424
});
1525

1626
// Use `app.import` to add additional libraries to the generated
@@ -28,3 +38,5 @@ module.exports = function (defaults) {
2838

2939
return app.toTree();
3040
};
41+
42+
module.exports.BUILD_SINCE = BUILD_SINCE;

package-lock.json

Lines changed: 32 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
},
2323
"scripts": {
2424
"build": "ember build --environment=production",
25+
"build:prebuilt": "node ./scripts/update-prebuild.mjs",
2526
"lint": "npm-run-all --aggregate-output --continue-on-error --parallel \"lint:!(fix)\"",
2627
"lint:fix": "npm-run-all --aggregate-output --continue-on-error --parallel lint:*:fix",
2728
"lint:hbs": "ember-template-lint .",
@@ -49,6 +50,7 @@
4950
"babel-eslint": "^10.1.0",
5051
"broccoli-asset-rev": "^3.0.0",
5152
"chai": "^4.3.4",
53+
"compare-versions": "^6.0.0-rc.2",
5254
"ember-auto-import": "^2.6.1",
5355
"ember-cli": "~3.28.6",
5456
"ember-cli-app-version": "^5.0.0",
@@ -108,6 +110,7 @@
108110
"retext-repeated-words": "^3.0.0",
109111
"retext-spell": "^4.0.0",
110112
"retext-syntax-urls": "^2.0.0",
113+
"shelljs": "^0.8.5",
111114
"unified": "^9.2.1",
112115
"walk-sync": "^2.0.2"
113116
},

scripts/update-prebuild.mjs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import shell from 'shelljs';
2+
import compareVersions from 'compare-versions';
3+
4+
import { exec as childProcessExec } from 'child_process';
5+
6+
import util from 'util';
7+
const exec = util.promisify(childProcessExec);
8+
9+
const { BUILD_SINCE } = await import('../ember-cli-build.js');
10+
11+
const anyChanges = shell.exec('git status --porcelain');
12+
13+
if (anyChanges.stdout) {
14+
console.log(
15+
'This script calls `git clean -xdf` to clean your current working directory before running'
16+
);
17+
console.log(
18+
'You have some un-committed changes in your branch, please clean them up before continuing.'
19+
);
20+
// eslint-disable-next-line no-process-exit, no-undef
21+
process.exit(1);
22+
}
23+
24+
shell.exec('git clean -xdf');
25+
26+
// this can't use shell.js because we cleared node_modules
27+
await exec('npm i');
28+
29+
shell.exec('rm public/assets/*');
30+
shell.exec('rm -rf public/v*');
31+
32+
shell.exec('ALL_VERSIONS=true ember build -prod');
33+
34+
shell.exec('cp -r dist/assets/* public/assets/');
35+
36+
shell
37+
.ls('dist')
38+
.filter((version) => version.startsWith('v'))
39+
.forEach(function (versionFolder) {
40+
if (compareVersions.compare(versionFolder, BUILD_SINCE, '<')) {
41+
shell.exec(`cp -r dist/${versionFolder} public`);
42+
}
43+
});

0 commit comments

Comments
 (0)