Repository navigation
Expand file tree
/
Copy pathcli.js
More file actions
executable file
·53 lines (41 loc) · 1.54 KB
/
Copy pathcli.js
File metadata and controls
executable file
·53 lines (41 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env node
const { exec } = require('child_process');
const fs = require('fs');
const path = require("path");
console.log('npx installation path', __dirname);
console.log('exec path', process.cwd());
let CONFIG;
const BUMP_RELEASE_CONFIG_PATH = process.env.BUMP_RELEASE_CONFIG_PATH || path.resolve('.bump-release.json');
if(fs.existsSync(BUMP_RELEASE_CONFIG_PATH)) {
CONFIG = JSON.parse(fs.readFileSync(BUMP_RELEASE_CONFIG_PATH, 'utf8'));
}
console.log(CONFIG);
// Example: bump-release /release/beta javascript-ex ./examples/javascript-ex javascript
const input = process.argv[2];
const name = process.argv[3];
console.log("Project Name: ", name);
const projectPath = process.argv[4] || CONFIG[name].path;
const resolver = process.argv[5] || CONFIG[name].resolver;
const bumpType = input?.split('/')[2];
const [GITHUB_REPO_OWNER, GITHUB_REPO_NAME] = process.env.GITHUB_REPOSITORY?.split('/') || [];
console.log("[@displaykit/releaser]");
const projectCwd = path.resolve(process.cwd(), projectPath);
const command = `
yarn --cwd ${__dirname} start version ${projectCwd} \
--type=${bumpType} \
--resolver=${resolver} \
--name=${name} \
--github-pull-request-number=${process.env.GITHUB_PR_NUMBER} \
--github-repo-owner=${GITHUB_REPO_OWNER} \
--github-repo-name=${GITHUB_REPO_NAME} \
--github-token=${process.env.GITHUB_TOKEN} \
--project-cwd=${projectCwd}
`;
console.log(command);
const run = exec(command, { encoding: 'utf8' });
run.stdout.on('data', (data) => {
console.log(data);
});
run.stderr.on('data', (data) => {
console.log(data);
});