Added (temporary) deploy scripts for pre-release extensions
Brian Vaughn committed
Feb 22, 2019 at 14:36 UTC
7b2f06e3d3960477a190b6a12238651596865284
9 files changed
+86
-13
package.json
+4
@@ -16,6 +16,10 @@
16
"build:extension:chrome": "node ./shells/browser/chrome/build",
17
"build:extension:firefox": "node ./shells/browser/firefox/build",
18
"build:standalone": "cd packages/react-devtools-core && yarn run build",
19
+ "deploy": "yarn run deploy:demo && yarn run deploy:chrome && yarn run deploy:firefox",
20
+ "deploy:demo": "cd shells/dev/ && now deploy && now alias react-devtools-experimental",
21
+ "deploy:chrome": "node ./shells/browser/chrome/deploy",
22
+ "deploy:firefox": "node ./shells/browser/firefox/deploy",
23
"linc": "lint-staged",
24
"lint": "eslint '**/*.js'",
25
"precommit": "lint-staged",
shells/browser/chrome/build.js
+1
-6
@@ -1,15 +1,10 @@
1
#!/usr/bin/env node
2
3
const chalk = require('chalk');
4
-const { join } = require('path');
4
const build = require('../shared/build');
5
6
const main = async () => {
8
- await build(
9
- 'chrome',
10
- join(__dirname, 'manifest.json'),
11
- join(__dirname, 'build')
12
- );
7
+ await build('chrome');
8
9
console.log(chalk.green('\nThe Chrome extension has been built!'));
10
console.log(chalk.green('You can test this build by running:'));
shells/browser/chrome/deploy.js
new
+7
@@ -0,0 +1,7 @@
1
+#!/usr/bin/env node
2
+
3
+const deploy = require('../shared/deploy');
4
+
5
+const main = async () => await deploy('chrome');
6
+
7
+main();
shells/browser/chrome/now.json
new
+5
@@ -0,0 +1,5 @@
1
+{
2
+ "name": "react-devtools-experimental-chrome",
3
+ "alias": ["react-devtools-experimental-chrome"],
4
+ "files": ["index.html", "packed.zip"]
5
+}
shells/browser/firefox/build.js
+3
-6
@@ -1,15 +1,10 @@
1
#!/usr/bin/env node
2
3
const chalk = require('chalk');
4
-const { join } = require('path');
4
const build = require('../shared/build');
5
6
const main = async () => {
8
- await build(
9
- 'firefox',
10
- join(__dirname, 'manifest.json'),
11
- join(__dirname, 'build')
12
- );
7
+ await build('firefox');
8
9
console.log(chalk.green('\nThe Firefox extension has been built!'));
10
console.log(chalk.green('You can test this build by running:'));
@@ -36,3 +31,5 @@ const main = async () => {
31
};
32
33
main();
34
+
35
+module.exports = { main };
shells/browser/firefox/deploy.js
new
+7
@@ -0,0 +1,7 @@
1
+#!/usr/bin/env node
2
+
3
+const deploy = require('../shared/deploy');
4
+
5
+const main = async () => await deploy('firefox');
6
+
7
+main();
shells/browser/firefox/now.json
new
+5
@@ -0,0 +1,5 @@
1
+{
2
+ "name": "react-devtools-experimental-firefox",
3
+ "alias": ["react-devtools-experimental-firefox"],
4
+ "files": ["index.html", "packed.zip"]
5
+}
shells/browser/shared/build.js
+5
-1
@@ -78,7 +78,11 @@ const postProcess = async (tempPath, destinationPath) => {
78
await remove(tempPath); // Clean up temp directory and files
79
};
80
81
-const main = async (buildId, manifestPath, destinationPath) => {
81
+const main = async buildId => {
82
+ const root = join(__dirname, '..', buildId);
83
+ const manifestPath = join(root, 'manifest.json');
84
+ const destinationPath = join(root, 'build');
85
+
86
try {
87
const tempPath = join(__dirname, 'build', buildId);
88
await preProcess(destinationPath, tempPath);
shells/browser/shared/deploy.js
new
+49
@@ -0,0 +1,49 @@
1
+#!/usr/bin/env node
2
+
3
+const { exec, execSync } = require('child_process');
4
+const { readFileSync, writeFileSync } = require('fs');
5
+const { join } = require('path');
6
+const build = require('./build');
7
+
8
+const main = async buildId => {
9
+ const root = join(__dirname, '..', buildId);
10
+ const buildPath = join(root, 'build');
11
+
12
+ await build(buildId);
13
+
14
+ await exec(`cp ${join(root, 'now.json')} ${join(buildPath, 'now.json')}`, {
15
+ cwd: root,
16
+ });
17
+
18
+ const file = readFileSync(join(root, 'now.json'));
19
+ const json = JSON.parse(file);
20
+ const alias = json.alias[0];
21
+
22
+ const commit = execSync('git rev-parse HEAD')
23
+ .toString()
24
+ .trim()
25
+ .substr(0, 7);
26
+ const date = new Date();
27
+
28
+ writeFileSync(
29
+ join(buildPath, 'index.html'),
30
+ `
31
+ <html>
32
+ <body>
33
+ <h1>${date.toLocaleDateString()} – ${date.toLocaleTimeString()}</h1>
34
+ <h2>Source <a href="http://github.com/bvaughn/react-devtools-experimental/commit/${commit}">${commit}</a></h2>
35
+ <a href="packed.zip">packed.zip</a>
36
+ </body>
37
+ </html>
38
+ `
39
+ );
40
+
41
+ await exec(`now deploy && now alias ${alias}`, {
42
+ cwd: buildPath,
43
+ stdio: 'inherit',
44
+ });
45
+
46
+ console.log(`Deployed to https://${alias}.now.sh`);
47
+};
48
+
49
+module.exports = main;