Skip to content

Commit 861a7cd

Browse files
committed
feat: add release script
1 parent 9b5bcb5 commit 861a7cd

File tree

6 files changed

+766
-577
lines changed

6 files changed

+766
-577
lines changed

package.json

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,13 @@
9292
"plugin-manager"
9393
],
9494
"scripts": {
95-
"watch": "npm-run-all -p watch:*",
95+
"watch": "yarn && npm-run-all -p watch:*",
9696
"watch:extension": "tsc --watch -p ./src",
9797
"watch:webviews": "webpack --watch",
98-
"build": "npm-run-all -p build:*",
98+
"build": "yarn && npm-run-all -p build:*",
9999
"build:extension": "tsc -p ./src",
100100
"build:webviews": "webpack",
101-
"release": "node ./scripts/release.js"
101+
"release": "yarn && node ./scripts/release.js"
102102
},
103103
"husky": {
104104
"hooks": {
@@ -117,17 +117,10 @@
117117
"axios": "^0.21.0",
118118
"classnames": "^2.2.6",
119119
"isomorphic-git": "^1.8.0",
120-
"querystring": "^0.2.0",
121-
"react": "^17.0.1",
122-
"react-dom": "^17.0.1",
123-
"react-select": "^3.1.1"
120+
"querystring": "^0.2.0"
124121
},
125122
"devDependencies": {
126-
"@types/classnames": "^2.2.11",
127123
"@types/node": "^14.14.7",
128-
"@types/react": "^16.9.56",
129-
"@types/react-dom": "^16.9.9",
130-
"@types/react-select": "^3.0.26",
131124
"@typescript-eslint/eslint-plugin": "^4.7.0",
132125
"@typescript-eslint/parser": "^4.7.0",
133126
"css-loader": "^5.0.1",
@@ -136,6 +129,7 @@
136129
"lint-staged": "^10.5.1",
137130
"npm-run-all": "^4.1.5",
138131
"prettier": "^2.1.2",
132+
"shelljs": "^0.8.4",
139133
"style-loader": "^2.0.0",
140134
"ts-loader": "^8.0.11",
141135
"typescript": "^4.0.5",

scripts/release.js

Lines changed: 12 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,17 @@
1-
const fs = require('fs').promises;
2-
const oldFS = require('fs');
3-
const path = require('path');
4-
const childProcess = require('child_process');
1+
const shell = require('shelljs')
52

6-
const ROOT = path.resolve(__dirname, '../');
7-
const TEMP_PATH = path.resolve(ROOT, './temp');
8-
const OUT_PATH = path.resolve(ROOT, './out');
9-
const TEMP_OUT_PATH = path.resolve(TEMP_PATH, './out');
10-
const TEMP_NODE_MODULES = path.resolve(TEMP_PATH, './node_modules');
11-
const NODE_MODULES = path.resolve(ROOT, './node_modules');
3+
shell.pushd('./webviews')
4+
shell.exec('yarn')
125

13-
const copy = async (source, destination) => {
14-
let paths = await fs.readdir(source);
15-
paths.forEach(async (path) => {
16-
const _source = source + '/' + path;
17-
const _destination = destination + '/' + path;
18-
try {
19-
const stats = await fs.stat(_source);
20-
if (stats.isFile()) {
21-
const readable = oldFS.createReadStream(_source);
22-
const writable = oldFS.createWriteStream(_destination);
23-
readable.pipe(writable);
24-
} else if (stats.isDirectory()) {
25-
checkDirectory(_source, _destination, copy);
26-
}
27-
} catch {
6+
shell.popd()
7+
shell.exec('yarn')
8+
shell.exec('yarn build')
289

29-
}
30-
});
31-
}
10+
shell.mkdir('-p', ['./temp/out', './temp/node_modules'])
11+
shell.cp('-Rf', './out/*', './temp/out/')
3212

33-
const checkDirectory = async (source, destination, callback) => {
34-
try {
35-
const res = await fs.stat(destination);
36-
callback(source, destination);
37-
} catch {
38-
const res = await fs.mkdir(destination);
39-
callback(source, destination);
40-
}
41-
};
13+
shell.exec('yarn --prod=true')
14+
shell.cp('-Rf', './node_modules/*', './temp/node_modules/')
4215

43-
const release = async () => {
44-
try {
45-
await fs.stat(TEMP_PATH);
46-
} catch {
47-
await fs.mkdir(TEMP_PATH);
48-
}
49-
50-
try {
51-
await fs.stat(TEMP_OUT_PATH);
52-
} catch {
53-
await fs.mkdir(TEMP_OUT_PATH);
54-
}
55-
56-
try {
57-
await fs.stat(TEMP_NODE_MODULES);
58-
} catch {
59-
await fs.mkdir(TEMP_NODE_MODULES);
60-
}
61-
62-
childProcess.execSync('yarn');
63-
childProcess.execSync('yarn build');
64-
console.warn('yarn build complete')
65-
66-
await copy(OUT_PATH, TEMP_PATH + '/out');
67-
await fs.copyFile(path.resolve(ROOT, './package.json'), path.resolve(TEMP_PATH, './package.json'));
68-
await fs.copyFile(path.resolve(ROOT, './LICENSE'), path.resolve(TEMP_PATH, './LICENSE'));
69-
70-
childProcess.execSync('yarn --prod=true');
71-
await copy(NODE_MODULES, TEMP_PATH + '/node_modules');
72-
73-
childProcess.execSync(`rm -rf ${path.resolve(TEMP_NODE_MODULES, './@babel')}`);
74-
childProcess.execSync(`rm -rf ${path.resolve(TEMP_NODE_MODULES, './@emotion')}`);
75-
childProcess.execSync(`rm -rf ${path.resolve(TEMP_NODE_MODULES, './csstype')}`);
76-
childProcess.execSync(`rm -rf ${path.resolve(TEMP_NODE_MODULES, './babel-plugin-emotion')}`);
77-
childProcess.execSync(`rm -rf ${path.resolve(TEMP_NODE_MODULES, './babel-plugin-macros')}`);
78-
childProcess.execSync(`rm -rf ${path.resolve(TEMP_NODE_MODULES, './babel-plugin-syntax-jsx')}`);
79-
};
80-
81-
release();
16+
shell.cp('./package.json', './temp/')
17+
shell.cp('./LICENSE', './temp/')

webviews/components/DepotSelect/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const DepotSelect = () => {
4040

4141
const getOptionLabel = ({ name, depotPath }: IDepot) => {
4242
const project = getDepotProject(depotPath);
43-
return name === project ? name : `${name} (${project})`;
43+
return `${project}/${name}`;
4444
};
4545

4646
return (

webviews/package.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "webviews",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"build": "webpack",
8+
"watch": "webpack --watch"
9+
},
10+
"keywords": [],
11+
"author": "",
12+
"license": "ISC",
13+
"dependencies": {
14+
"axios": "^0.21.0",
15+
"classnames": "^2.2.6",
16+
"querystring": "^0.2.0",
17+
"react": "^17.0.1",
18+
"react-dom": "^17.0.1",
19+
"react-select": "^3.1.1"
20+
},
21+
"devDependencies": {
22+
"@types/classnames": "^2.2.11",
23+
"@types/react": "^16.9.56",
24+
"@types/react-dom": "^16.9.9",
25+
"@types/react-select": "^3.0.26"
26+
}
27+
}

0 commit comments

Comments
 (0)