@uirouter/publish-scripts 2.6.1 → 2.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -3
- package/actions/upgrade/Dockerfile +7 -7
- package/actions/upgrade/action.yml +24 -24
- package/actions/upgrade/entrypoint.sh +3 -3
- package/actions/upgrade/package.json +8 -8
- package/actions/upgrade/upgrade.js +59 -59
- package/artifact_tagging.js +108 -108
- package/docgen/Dockerfile +14 -14
- package/docgen/clone.sh +10 -10
- package/docgen/docgen.sh +27 -27
- package/docgen/docker_push.sh +9 -9
- package/docgen/package.json +7 -7
- package/docgen/prep_docgen.js +58 -58
- package/docgen_via_docker.sh +3 -3
- package/ensure_clean_master.js +10 -10
- package/modify_sourcemap_paths.js +28 -28
- package/package.json +2 -2
- package/publish_docs.js +46 -46
- package/publish_yalc_package.js +117 -117
- package/release.js +164 -164
- package/show_changelog.js +142 -142
- package/show_version.js +110 -110
- package/test_downstream_projects.js +303 -303
- package/util.js +50 -50
package/docgen/prep_docgen.js
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const childProcess = require('child_process');
|
|
4
|
-
|
|
5
|
-
const WORKDIR = process.cwd();
|
|
6
|
-
const PACKAGE_DIR = `${WORKDIR}/project`;
|
|
7
|
-
const SRC_DIR = `${PACKAGE_DIR}/src`;
|
|
8
|
-
const PACKAGEJSON_PATH = `${PACKAGE_DIR}/package.json`;
|
|
9
|
-
|
|
10
|
-
if (!fs.existsSync(SRC_DIR)) { throw new Error(`${SRC_DIR} does not exist`) }
|
|
11
|
-
if (!fs.existsSync(PACKAGEJSON_PATH)) { throw new Error(`${PACKAGEJSON_PATH} does not exist`); }
|
|
12
|
-
|
|
13
|
-
const PACKAGEJSON = JSON.parse(fs.readFileSync(PACKAGEJSON_PATH));
|
|
14
|
-
const DOCGENCONFIG = getDocgenConfig(PACKAGEJSON);
|
|
15
|
-
|
|
16
|
-
function getDocgenConfig(packageJson) {
|
|
17
|
-
const requiredKeys = ['docgen', 'docgen.navigation', 'docgen.publishDir'];
|
|
18
|
-
const missing = requiredKeys.find((key) => key.split(".").reduce((acc, k) => acc && acc[k], packageJson) === undefined);
|
|
19
|
-
if (missing) {
|
|
20
|
-
console.error(`${PACKAGEJSON_PATH} does not contain configuration key: '${missing}'`);
|
|
21
|
-
process.exit(1);
|
|
22
|
-
}
|
|
23
|
-
return packageJson.docgen;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// Fetch all included packages (i.e., core module)
|
|
27
|
-
const CLONE_COMMANDS = ['#!/usr/bin/env bash', 'set -x'];
|
|
28
|
-
|
|
29
|
-
(DOCGENCONFIG.include || []).forEach(include => {
|
|
30
|
-
const { pkg, repo, branch } = include;
|
|
31
|
-
const semver = ['peerDependencies', 'dependencies', 'devDependencies']
|
|
32
|
-
.map((key) => (PACKAGEJSON[key] || {})[pkg])
|
|
33
|
-
.find((x) => !!x);
|
|
34
|
-
|
|
35
|
-
const version = branch || findSemverPackage(pkg, semver);
|
|
36
|
-
CLONE_COMMANDS.push(`./clone.sh ${repo} ${PACKAGE_DIR}/src/includes/${pkg} ${version}`);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
fs.writeFileSync('clone_repos.sh', CLONE_COMMANDS.join('\n'));
|
|
40
|
-
|
|
41
|
-
// Finds the newest version of a package published to NPM that matches the desired semver range
|
|
42
|
-
function findSemverPackage(packageName, semver) {
|
|
43
|
-
const stdout = childProcess.execSync(`npm info ${packageName}@${semver} version`).toString();
|
|
44
|
-
const lines = stdout.split(/\n/).filter(x => x.length);
|
|
45
|
-
if (lines.length === 0) {
|
|
46
|
-
throw new Error(`No published package matched ${packageName}@${semver}`)
|
|
47
|
-
} else if (lines.length === 1) {
|
|
48
|
-
return lines[ 0 ];
|
|
49
|
-
} else {
|
|
50
|
-
const line = stdout.trim().split(/\n/).pop().trim();
|
|
51
|
-
const [, version] = /.* '(.*)'$/.exec(line) || [];
|
|
52
|
-
if (!version) {
|
|
53
|
-
console.log({ stdout, line });
|
|
54
|
-
throw new Error(`Couldn't find version matching ${packageName}@${semver} in npm registry`)
|
|
55
|
-
}
|
|
56
|
-
return version;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const childProcess = require('child_process');
|
|
4
|
+
|
|
5
|
+
const WORKDIR = process.cwd();
|
|
6
|
+
const PACKAGE_DIR = `${WORKDIR}/project`;
|
|
7
|
+
const SRC_DIR = `${PACKAGE_DIR}/src`;
|
|
8
|
+
const PACKAGEJSON_PATH = `${PACKAGE_DIR}/package.json`;
|
|
9
|
+
|
|
10
|
+
if (!fs.existsSync(SRC_DIR)) { throw new Error(`${SRC_DIR} does not exist`) }
|
|
11
|
+
if (!fs.existsSync(PACKAGEJSON_PATH)) { throw new Error(`${PACKAGEJSON_PATH} does not exist`); }
|
|
12
|
+
|
|
13
|
+
const PACKAGEJSON = JSON.parse(fs.readFileSync(PACKAGEJSON_PATH));
|
|
14
|
+
const DOCGENCONFIG = getDocgenConfig(PACKAGEJSON);
|
|
15
|
+
|
|
16
|
+
function getDocgenConfig(packageJson) {
|
|
17
|
+
const requiredKeys = ['docgen', 'docgen.navigation', 'docgen.publishDir'];
|
|
18
|
+
const missing = requiredKeys.find((key) => key.split(".").reduce((acc, k) => acc && acc[k], packageJson) === undefined);
|
|
19
|
+
if (missing) {
|
|
20
|
+
console.error(`${PACKAGEJSON_PATH} does not contain configuration key: '${missing}'`);
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
return packageJson.docgen;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Fetch all included packages (i.e., core module)
|
|
27
|
+
const CLONE_COMMANDS = ['#!/usr/bin/env bash', 'set -x'];
|
|
28
|
+
|
|
29
|
+
(DOCGENCONFIG.include || []).forEach(include => {
|
|
30
|
+
const { pkg, repo, branch } = include;
|
|
31
|
+
const semver = ['peerDependencies', 'dependencies', 'devDependencies']
|
|
32
|
+
.map((key) => (PACKAGEJSON[key] || {})[pkg])
|
|
33
|
+
.find((x) => !!x);
|
|
34
|
+
|
|
35
|
+
const version = branch || findSemverPackage(pkg, semver);
|
|
36
|
+
CLONE_COMMANDS.push(`./clone.sh ${repo} ${PACKAGE_DIR}/src/includes/${pkg} ${version}`);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
fs.writeFileSync('clone_repos.sh', CLONE_COMMANDS.join('\n'));
|
|
40
|
+
|
|
41
|
+
// Finds the newest version of a package published to NPM that matches the desired semver range
|
|
42
|
+
function findSemverPackage(packageName, semver) {
|
|
43
|
+
const stdout = childProcess.execSync(`npm info ${packageName}@${semver} version`).toString();
|
|
44
|
+
const lines = stdout.split(/\n/).filter(x => x.length);
|
|
45
|
+
if (lines.length === 0) {
|
|
46
|
+
throw new Error(`No published package matched ${packageName}@${semver}`)
|
|
47
|
+
} else if (lines.length === 1) {
|
|
48
|
+
return lines[ 0 ];
|
|
49
|
+
} else {
|
|
50
|
+
const line = stdout.trim().split(/\n/).pop().trim();
|
|
51
|
+
const [, version] = /.* '(.*)'$/.exec(line) || [];
|
|
52
|
+
if (!version) {
|
|
53
|
+
console.log({ stdout, line });
|
|
54
|
+
throw new Error(`Couldn't find version matching ${packageName}@${semver} in npm registry`)
|
|
55
|
+
}
|
|
56
|
+
return version;
|
|
57
|
+
}
|
|
58
|
+
}
|
package/docgen_via_docker.sh
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
set -ex
|
|
3
|
-
docker run -v `pwd`:/home/node/work/project uirouter/docgen:stable
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -ex
|
|
3
|
+
docker run -v `pwd`:/home/node/work/project uirouter/docgen:stable
|
package/ensure_clean_master.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const util = require('./util');
|
|
4
|
-
util.packageDir();
|
|
5
|
-
|
|
6
|
-
let branch;
|
|
7
|
-
if(require.main === module && process.argv[2])
|
|
8
|
-
branch = process.argv[2];
|
|
9
|
-
|
|
10
|
-
util.ensureCleanMaster(branch);
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const util = require('./util');
|
|
4
|
+
util.packageDir();
|
|
5
|
+
|
|
6
|
+
let branch;
|
|
7
|
+
if(require.main === module && process.argv[2])
|
|
8
|
+
branch = process.argv[2];
|
|
9
|
+
|
|
10
|
+
util.ensureCleanMaster(branch);
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
require('./util').packageDir();
|
|
4
|
-
require('shelljs/global');
|
|
5
|
-
|
|
6
|
-
const fs = require('fs');
|
|
7
|
-
const path = require('path');
|
|
8
|
-
const glob = require('glob');
|
|
9
|
-
const pkg = JSON.parse(fs.readFileSync('./package.json'));
|
|
10
|
-
const allartifacts = JSON.parse(fs.readFileSync('./artifacts.json')).ARTIFACTS;
|
|
11
|
-
|
|
12
|
-
const globs = allartifacts
|
|
13
|
-
.filter(dir => fs.lstatSync(dir).isDirectory())
|
|
14
|
-
.map(dir => `${dir}/**/*.js.map`);
|
|
15
|
-
|
|
16
|
-
const files = globs
|
|
17
|
-
.map(pattern => glob.sync(pattern))
|
|
18
|
-
.reduce((acc, arr) => acc.concat(arr), []);
|
|
19
|
-
|
|
20
|
-
files.forEach(file => {
|
|
21
|
-
const data = JSON.parse(fs.readFileSync(file));
|
|
22
|
-
if (Array.isArray(data.sources)) {
|
|
23
|
-
data.sources = data.sources
|
|
24
|
-
.map(source => source.replace(/^(?:\.\.\/)*src/, pkg.name))
|
|
25
|
-
.map(source => source.replace(/^(?:\.\.\/)*node_modules\/@uirouter/, '@uirouter'));
|
|
26
|
-
fs.writeFileSync(file, JSON.stringify(data));
|
|
27
|
-
}
|
|
28
|
-
});
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
require('./util').packageDir();
|
|
4
|
+
require('shelljs/global');
|
|
5
|
+
|
|
6
|
+
const fs = require('fs');
|
|
7
|
+
const path = require('path');
|
|
8
|
+
const glob = require('glob');
|
|
9
|
+
const pkg = JSON.parse(fs.readFileSync('./package.json'));
|
|
10
|
+
const allartifacts = JSON.parse(fs.readFileSync('./artifacts.json')).ARTIFACTS;
|
|
11
|
+
|
|
12
|
+
const globs = allartifacts
|
|
13
|
+
.filter(dir => fs.lstatSync(dir).isDirectory())
|
|
14
|
+
.map(dir => `${dir}/**/*.js.map`);
|
|
15
|
+
|
|
16
|
+
const files = globs
|
|
17
|
+
.map(pattern => glob.sync(pattern))
|
|
18
|
+
.reduce((acc, arr) => acc.concat(arr), []);
|
|
19
|
+
|
|
20
|
+
files.forEach(file => {
|
|
21
|
+
const data = JSON.parse(fs.readFileSync(file));
|
|
22
|
+
if (Array.isArray(data.sources)) {
|
|
23
|
+
data.sources = data.sources
|
|
24
|
+
.map(source => source.replace(/^(?:\.\.\/)*src/, pkg.name))
|
|
25
|
+
.map(source => source.replace(/^(?:\.\.\/)*node_modules\/@uirouter/, '@uirouter'));
|
|
26
|
+
fs.writeFileSync(file, JSON.stringify(data));
|
|
27
|
+
}
|
|
28
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uirouter/publish-scripts",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.3",
|
|
4
4
|
"description": "Helper scripts for publishing UI-Router projects",
|
|
5
5
|
"main": "x",
|
|
6
6
|
"repository": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"util": "./util.js"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"check-peer-dependencies": "^4.
|
|
32
|
+
"check-peer-dependencies": "^4.3.0",
|
|
33
33
|
"conventional-changelog": "^3.1.24",
|
|
34
34
|
"conventional-changelog-ui-router-core": "^1.4.2",
|
|
35
35
|
"find-parent-dir": "^0.3.1",
|
package/publish_docs.js
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const publishYalcPackage = require('./publish_yalc_package');
|
|
4
|
-
const util = require('./util');
|
|
5
|
-
util.packageDir();
|
|
6
|
-
|
|
7
|
-
const fs = require('fs');
|
|
8
|
-
const path = require('path');
|
|
9
|
-
const _exec = util._exec;
|
|
10
|
-
const sh = require('shelljs');
|
|
11
|
-
const readlineSync = require('readline-sync');
|
|
12
|
-
|
|
13
|
-
const TYPEDOC_CONFIG = JSON.parse(fs.readFileSync('./typedoc.json'));
|
|
14
|
-
const PKGJSON = JSON.parse(fs.readFileSync('./package.json'));
|
|
15
|
-
const DOCGEN_CONFIG = PKGJSON.docgen || {};
|
|
16
|
-
const version = PKGJSON.version;
|
|
17
|
-
|
|
18
|
-
const GIT_URL = "git@github.com:ui-router/ui-router.github.io.git";
|
|
19
|
-
const installTargetDir = path.join(".downstream_cache", "ui-router.gihub.io");
|
|
20
|
-
const PAGES_DIR = path.join(installTargetDir, DOCGEN_CONFIG.publishDir);
|
|
21
|
-
|
|
22
|
-
sh.rm('-rf', installTargetDir);
|
|
23
|
-
_exec(`git clone ${GIT_URL} ${installTargetDir}`);
|
|
24
|
-
|
|
25
|
-
util.packageDir();
|
|
26
|
-
|
|
27
|
-
sh.rm('-rf', path.join(PAGES_DIR, 'latest'));
|
|
28
|
-
sh.cp('-r', TYPEDOC_CONFIG.out, path.join(PAGES_DIR, 'latest'));
|
|
29
|
-
|
|
30
|
-
sh.rm('-rf', path.join(PAGES_DIR, version));
|
|
31
|
-
sh.cp('-r', TYPEDOC_CONFIG.out, path.join(PAGES_DIR, version));
|
|
32
|
-
|
|
33
|
-
sh.cd(PAGES_DIR);
|
|
34
|
-
_exec("./process_docs.sh");
|
|
35
|
-
_exec("git add .");
|
|
36
|
-
|
|
37
|
-
sh.echo("\n\nSpot check the docs, then run these commands to publish:\n\n");
|
|
38
|
-
sh.echo("cd " + PAGES_DIR);
|
|
39
|
-
sh.echo(`git commit -m 'publish docs for ${version}'`);
|
|
40
|
-
sh.echo(`git push`);
|
|
41
|
-
|
|
42
|
-
if (readlineSync.keyInYN('Publish docs?')) {
|
|
43
|
-
sh.cd(PAGES_DIR);
|
|
44
|
-
_exec(`git commit -m 'publish docs for ${version}'`);
|
|
45
|
-
_exec(`git push`);
|
|
46
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const publishYalcPackage = require('./publish_yalc_package');
|
|
4
|
+
const util = require('./util');
|
|
5
|
+
util.packageDir();
|
|
6
|
+
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
const path = require('path');
|
|
9
|
+
const _exec = util._exec;
|
|
10
|
+
const sh = require('shelljs');
|
|
11
|
+
const readlineSync = require('readline-sync');
|
|
12
|
+
|
|
13
|
+
const TYPEDOC_CONFIG = JSON.parse(fs.readFileSync('./typedoc.json'));
|
|
14
|
+
const PKGJSON = JSON.parse(fs.readFileSync('./package.json'));
|
|
15
|
+
const DOCGEN_CONFIG = PKGJSON.docgen || {};
|
|
16
|
+
const version = PKGJSON.version;
|
|
17
|
+
|
|
18
|
+
const GIT_URL = "git@github.com:ui-router/ui-router.github.io.git";
|
|
19
|
+
const installTargetDir = path.join(".downstream_cache", "ui-router.gihub.io");
|
|
20
|
+
const PAGES_DIR = path.join(installTargetDir, DOCGEN_CONFIG.publishDir);
|
|
21
|
+
|
|
22
|
+
sh.rm('-rf', installTargetDir);
|
|
23
|
+
_exec(`git clone ${GIT_URL} ${installTargetDir}`);
|
|
24
|
+
|
|
25
|
+
util.packageDir();
|
|
26
|
+
|
|
27
|
+
sh.rm('-rf', path.join(PAGES_DIR, 'latest'));
|
|
28
|
+
sh.cp('-r', TYPEDOC_CONFIG.out, path.join(PAGES_DIR, 'latest'));
|
|
29
|
+
|
|
30
|
+
sh.rm('-rf', path.join(PAGES_DIR, version));
|
|
31
|
+
sh.cp('-r', TYPEDOC_CONFIG.out, path.join(PAGES_DIR, version));
|
|
32
|
+
|
|
33
|
+
sh.cd(PAGES_DIR);
|
|
34
|
+
_exec("./process_docs.sh");
|
|
35
|
+
_exec("git add .");
|
|
36
|
+
|
|
37
|
+
sh.echo("\n\nSpot check the docs, then run these commands to publish:\n\n");
|
|
38
|
+
sh.echo("cd " + PAGES_DIR);
|
|
39
|
+
sh.echo(`git commit -m 'publish docs for ${version}'`);
|
|
40
|
+
sh.echo(`git push`);
|
|
41
|
+
|
|
42
|
+
if (readlineSync.keyInYN('Publish docs?')) {
|
|
43
|
+
sh.cd(PAGES_DIR);
|
|
44
|
+
_exec(`git commit -m 'publish docs for ${version}'`);
|
|
45
|
+
_exec(`git push`);
|
|
46
|
+
}
|
package/publish_yalc_package.js
CHANGED
|
@@ -1,117 +1,117 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// This script is intended to fetch a package from a git url and publish it locally using the npm package `yalc`.
|
|
4
|
-
// That package can then be installed from the local yalc registry an tested against by some downstream project.
|
|
5
|
-
// This script can optionally fetch from a local directory instead of a git repository.
|
|
6
|
-
|
|
7
|
-
// The script leaves the files in place after publishing.
|
|
8
|
-
// This can be handy in Travis which can cache the directory contents.
|
|
9
|
-
// After caching, subsequent re-runs of this script won't have to fetch the git repository (or do much for `yarn install`).
|
|
10
|
-
const fs = require('fs');
|
|
11
|
-
const path = require('path');
|
|
12
|
-
const shelljs = require('shelljs');
|
|
13
|
-
const tmp = require('tmp');
|
|
14
|
-
const util = require('./util');
|
|
15
|
-
|
|
16
|
-
const ORIG_DIR = process.cwd();
|
|
17
|
-
|
|
18
|
-
function publishYalcPackage(installTargetDir, installSource, flags) {
|
|
19
|
-
flags = flags || {};
|
|
20
|
-
const branch = flags.branch || 'origin/master';
|
|
21
|
-
|
|
22
|
-
if (!installTargetDir || !installSource) {
|
|
23
|
-
throw new Error('Usage: publish_yalc_package [INSTALL_DIR] [GITHUB_URL|LOCAL_DIR]');
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
installTargetDir = path.resolve(installTargetDir);
|
|
27
|
-
const isRemoteSource = !/^\./.exec(installSource);
|
|
28
|
-
const installTargetDirTmp = path.join(installTargetDir, ".tmp");
|
|
29
|
-
const installSourceDir = isRemoteSource ? null : path.resolve(installSource);
|
|
30
|
-
|
|
31
|
-
// Create directory and clone git repo
|
|
32
|
-
if (!fs.existsSync(path.join(installTargetDir, '.git'))) {
|
|
33
|
-
if (isRemoteSource) {
|
|
34
|
-
util._exec(`git clone ${installSource} ${installTargetDir}`);
|
|
35
|
-
} else {
|
|
36
|
-
shelljs.rm('-rf', installTargetDir);
|
|
37
|
-
shelljs.cp('-r', installSourceDir, installTargetDir);
|
|
38
|
-
process.chdir(installTargetDir);
|
|
39
|
-
util._exec(`git init && git add . && git commit -m "initial commit"`);
|
|
40
|
-
process.chdir(ORIG_DIR);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// Update git repo from source and make working copy match exactly
|
|
45
|
-
if (isRemoteSource) {
|
|
46
|
-
process.chdir(installTargetDir);
|
|
47
|
-
util._exec('git fetch origin');
|
|
48
|
-
util._exec(`git checkout ${branch}`);
|
|
49
|
-
util._exec(`git reset --hard ${branch}`);
|
|
50
|
-
util._exec('git clean --force -d');
|
|
51
|
-
} else {
|
|
52
|
-
// Create a tmp dir with a copy of the current package contents
|
|
53
|
-
shelljs.rm('-rf', installTargetDirTmp);
|
|
54
|
-
shelljs.cp('-r', installSourceDir, installTargetDirTmp);
|
|
55
|
-
|
|
56
|
-
// Copy the current .git metadata from the cache dir into the tmp dir
|
|
57
|
-
shelljs.cp('-r', path.join(installTargetDir, ".git"), installTargetDirTmp);
|
|
58
|
-
process.chdir(installTargetDirTmp);
|
|
59
|
-
|
|
60
|
-
// Commit the changes from the current package (if any)
|
|
61
|
-
util._exec('git add . && git diff --staged --quiet || git commit -m "update from source directory"');
|
|
62
|
-
|
|
63
|
-
process.chdir(installTargetDir);
|
|
64
|
-
|
|
65
|
-
// Move the new .git metadata back into the cache dir
|
|
66
|
-
shelljs.rm('-rf', '.git');
|
|
67
|
-
shelljs.mv(path.join('.tmp', '.git'), ".");
|
|
68
|
-
shelljs.rm('-rf', installTargetDirTmp);
|
|
69
|
-
|
|
70
|
-
// Update the cache to match the current package contents
|
|
71
|
-
util._exec('git reset --hard master');
|
|
72
|
-
util._exec('git clean --force -d');
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// Update dependencies
|
|
76
|
-
if (!flags.noInstall) {
|
|
77
|
-
util._exec('yarn install --check-files');
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const TEMP = tmp.dirSync();
|
|
81
|
-
const TEMP_DIR = TEMP.name;
|
|
82
|
-
const BUILD_TEMP_DIR = path.resolve(TEMP_DIR, path.basename(installTargetDir));
|
|
83
|
-
if (!flags.noBuild || !flags.noPublish) {
|
|
84
|
-
try {
|
|
85
|
-
shelljs.mv(installTargetDir, TEMP_DIR);
|
|
86
|
-
process.chdir(BUILD_TEMP_DIR);
|
|
87
|
-
|
|
88
|
-
const pkgJson = JSON.parse(fs.readFileSync('package.json'));
|
|
89
|
-
if (!flags.noBuild) {
|
|
90
|
-
// Build package
|
|
91
|
-
if (pkgJson.scripts && pkgJson.scripts.build) {
|
|
92
|
-
util._exec('npm run build');
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// If ngPackage is found in package.json, the directory to be published is actually ./dist
|
|
97
|
-
const distDir = pkgJson.distDir || '.';
|
|
98
|
-
if (!flags.noPublish) {
|
|
99
|
-
shelljs.pushd(distDir);
|
|
100
|
-
// Publish to local yalc registry
|
|
101
|
-
util._exec('npx yalc publish');
|
|
102
|
-
shelljs.popd();
|
|
103
|
-
}
|
|
104
|
-
} finally {
|
|
105
|
-
shelljs.mv(BUILD_TEMP_DIR, installTargetDir);
|
|
106
|
-
shelljs.rm('-rf', TEMP_DIR);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
process.chdir(ORIG_DIR);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (require.main === module) {
|
|
114
|
-
publishYalcPackage(process.argv[2], process.argv[3])
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
module.exports = publishYalcPackage;
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// This script is intended to fetch a package from a git url and publish it locally using the npm package `yalc`.
|
|
4
|
+
// That package can then be installed from the local yalc registry an tested against by some downstream project.
|
|
5
|
+
// This script can optionally fetch from a local directory instead of a git repository.
|
|
6
|
+
|
|
7
|
+
// The script leaves the files in place after publishing.
|
|
8
|
+
// This can be handy in Travis which can cache the directory contents.
|
|
9
|
+
// After caching, subsequent re-runs of this script won't have to fetch the git repository (or do much for `yarn install`).
|
|
10
|
+
const fs = require('fs');
|
|
11
|
+
const path = require('path');
|
|
12
|
+
const shelljs = require('shelljs');
|
|
13
|
+
const tmp = require('tmp');
|
|
14
|
+
const util = require('./util');
|
|
15
|
+
|
|
16
|
+
const ORIG_DIR = process.cwd();
|
|
17
|
+
|
|
18
|
+
function publishYalcPackage(installTargetDir, installSource, flags) {
|
|
19
|
+
flags = flags || {};
|
|
20
|
+
const branch = flags.branch || 'origin/master';
|
|
21
|
+
|
|
22
|
+
if (!installTargetDir || !installSource) {
|
|
23
|
+
throw new Error('Usage: publish_yalc_package [INSTALL_DIR] [GITHUB_URL|LOCAL_DIR]');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
installTargetDir = path.resolve(installTargetDir);
|
|
27
|
+
const isRemoteSource = !/^\./.exec(installSource);
|
|
28
|
+
const installTargetDirTmp = path.join(installTargetDir, ".tmp");
|
|
29
|
+
const installSourceDir = isRemoteSource ? null : path.resolve(installSource);
|
|
30
|
+
|
|
31
|
+
// Create directory and clone git repo
|
|
32
|
+
if (!fs.existsSync(path.join(installTargetDir, '.git'))) {
|
|
33
|
+
if (isRemoteSource) {
|
|
34
|
+
util._exec(`git clone ${installSource} ${installTargetDir}`);
|
|
35
|
+
} else {
|
|
36
|
+
shelljs.rm('-rf', installTargetDir);
|
|
37
|
+
shelljs.cp('-r', installSourceDir, installTargetDir);
|
|
38
|
+
process.chdir(installTargetDir);
|
|
39
|
+
util._exec(`git init && git add . && git commit -m "initial commit"`);
|
|
40
|
+
process.chdir(ORIG_DIR);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Update git repo from source and make working copy match exactly
|
|
45
|
+
if (isRemoteSource) {
|
|
46
|
+
process.chdir(installTargetDir);
|
|
47
|
+
util._exec('git fetch origin');
|
|
48
|
+
util._exec(`git checkout ${branch}`);
|
|
49
|
+
util._exec(`git reset --hard ${branch}`);
|
|
50
|
+
util._exec('git clean --force -d');
|
|
51
|
+
} else {
|
|
52
|
+
// Create a tmp dir with a copy of the current package contents
|
|
53
|
+
shelljs.rm('-rf', installTargetDirTmp);
|
|
54
|
+
shelljs.cp('-r', installSourceDir, installTargetDirTmp);
|
|
55
|
+
|
|
56
|
+
// Copy the current .git metadata from the cache dir into the tmp dir
|
|
57
|
+
shelljs.cp('-r', path.join(installTargetDir, ".git"), installTargetDirTmp);
|
|
58
|
+
process.chdir(installTargetDirTmp);
|
|
59
|
+
|
|
60
|
+
// Commit the changes from the current package (if any)
|
|
61
|
+
util._exec('git add . && git diff --staged --quiet || git commit -m "update from source directory"');
|
|
62
|
+
|
|
63
|
+
process.chdir(installTargetDir);
|
|
64
|
+
|
|
65
|
+
// Move the new .git metadata back into the cache dir
|
|
66
|
+
shelljs.rm('-rf', '.git');
|
|
67
|
+
shelljs.mv(path.join('.tmp', '.git'), ".");
|
|
68
|
+
shelljs.rm('-rf', installTargetDirTmp);
|
|
69
|
+
|
|
70
|
+
// Update the cache to match the current package contents
|
|
71
|
+
util._exec('git reset --hard master');
|
|
72
|
+
util._exec('git clean --force -d');
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Update dependencies
|
|
76
|
+
if (!flags.noInstall) {
|
|
77
|
+
util._exec('yarn install --check-files');
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const TEMP = tmp.dirSync();
|
|
81
|
+
const TEMP_DIR = TEMP.name;
|
|
82
|
+
const BUILD_TEMP_DIR = path.resolve(TEMP_DIR, path.basename(installTargetDir));
|
|
83
|
+
if (!flags.noBuild || !flags.noPublish) {
|
|
84
|
+
try {
|
|
85
|
+
shelljs.mv(installTargetDir, TEMP_DIR);
|
|
86
|
+
process.chdir(BUILD_TEMP_DIR);
|
|
87
|
+
|
|
88
|
+
const pkgJson = JSON.parse(fs.readFileSync('package.json'));
|
|
89
|
+
if (!flags.noBuild) {
|
|
90
|
+
// Build package
|
|
91
|
+
if (pkgJson.scripts && pkgJson.scripts.build) {
|
|
92
|
+
util._exec('npm run build');
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// If ngPackage is found in package.json, the directory to be published is actually ./dist
|
|
97
|
+
const distDir = pkgJson.distDir || '.';
|
|
98
|
+
if (!flags.noPublish) {
|
|
99
|
+
shelljs.pushd(distDir);
|
|
100
|
+
// Publish to local yalc registry
|
|
101
|
+
util._exec('npx yalc publish');
|
|
102
|
+
shelljs.popd();
|
|
103
|
+
}
|
|
104
|
+
} finally {
|
|
105
|
+
shelljs.mv(BUILD_TEMP_DIR, installTargetDir);
|
|
106
|
+
shelljs.rm('-rf', TEMP_DIR);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
process.chdir(ORIG_DIR);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (require.main === module) {
|
|
114
|
+
publishYalcPackage(process.argv[2], process.argv[3])
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
module.exports = publishYalcPackage;
|