@edifice.io/cli 1.6.0-develop-docker.0 → 1.6.0-develop-b2school.11
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/LICENSE +661 -661
- package/bin/index.js +125 -125
- package/package.json +1 -1
- package/src/publish/index.d.ts +37 -37
- package/src/publish/index.js +445 -465
- package/src/publish/utilities.js +50 -50
package/bin/index.js
CHANGED
|
@@ -1,125 +1,125 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { program } from "commander";
|
|
4
|
-
import interpret from "interpret";
|
|
5
|
-
import Liftoff from "liftoff";
|
|
6
|
-
import minimist from "minimist";
|
|
7
|
-
import { readFileSync } from "node:fs";
|
|
8
|
-
import { createRequire } from "node:module";
|
|
9
|
-
import { dirname, join } from "node:path";
|
|
10
|
-
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
11
|
-
import v8flags from "v8flags";
|
|
12
|
-
import { publish } from "../src/publish/index.js";
|
|
13
|
-
|
|
14
|
-
const args = process.argv.slice(2);
|
|
15
|
-
const argv = minimist(args);
|
|
16
|
-
|
|
17
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
18
|
-
const pkg = JSON.parse(
|
|
19
|
-
readFileSync(join(__dirname, "../package.json"), "utf8"),
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
const require = createRequire(import.meta.url);
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* @param {string} [path]
|
|
26
|
-
*/
|
|
27
|
-
async function requireOrImport(path) {
|
|
28
|
-
if (!path) return null;
|
|
29
|
-
try {
|
|
30
|
-
return require(path);
|
|
31
|
-
} catch (e) {
|
|
32
|
-
// @ts-expect-error
|
|
33
|
-
if (e.code === "ERR_REQUIRE_ESM") {
|
|
34
|
-
// This is needed on Windows, because import() fails if providing a Windows file path.
|
|
35
|
-
const url = pathToFileURL(path);
|
|
36
|
-
// @ts-expect-error
|
|
37
|
-
return import(url);
|
|
38
|
-
}
|
|
39
|
-
throw e;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const Config = new Liftoff({
|
|
44
|
-
name: "edifice-config",
|
|
45
|
-
configName: "edifice.config",
|
|
46
|
-
// @ts-expect-error
|
|
47
|
-
extensions: interpret.jsVariants,
|
|
48
|
-
preload: "esbuild-register/dist/node",
|
|
49
|
-
v8flags,
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* @param {string} [configPath]
|
|
54
|
-
*/
|
|
55
|
-
function checkForConfigFile(configPath) {
|
|
56
|
-
if (configPath) return;
|
|
57
|
-
console.error(
|
|
58
|
-
[
|
|
59
|
-
"No edifice.config.js file found!",
|
|
60
|
-
"This may be because you're not passing the --config or --cwd flags.",
|
|
61
|
-
"If you are passing these flags, check that the path is correct.",
|
|
62
|
-
"Otherwise, you can create a `edifice.config.js` file in your project root.",
|
|
63
|
-
].join("\n"),
|
|
64
|
-
);
|
|
65
|
-
process.exit(1);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
Config.prepare(
|
|
69
|
-
{
|
|
70
|
-
cwd: argv.cwd,
|
|
71
|
-
configPath: argv.config,
|
|
72
|
-
completion: argv.completion,
|
|
73
|
-
},
|
|
74
|
-
(prepEnv) => {
|
|
75
|
-
Config.execute(prepEnv, (env) => {
|
|
76
|
-
requireOrImport(env.configPath)
|
|
77
|
-
.then((configOpts) => {
|
|
78
|
-
program
|
|
79
|
-
.name("@edifice.io/cli")
|
|
80
|
-
.description(
|
|
81
|
-
"Configuration and tools for publishing and maintaining packages",
|
|
82
|
-
)
|
|
83
|
-
.version(pkg.version);
|
|
84
|
-
|
|
85
|
-
if (configOpts) {
|
|
86
|
-
for (const key of Object.keys(configOpts)) {
|
|
87
|
-
program.setOptionValueWithSource(key, configOpts[key], "config");
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
program
|
|
92
|
-
.command("publish")
|
|
93
|
-
.description(
|
|
94
|
-
"Publish your package with the current working directory",
|
|
95
|
-
)
|
|
96
|
-
.option(
|
|
97
|
-
"--cwd <dir>",
|
|
98
|
-
"Current working directory of the configuration file",
|
|
99
|
-
)
|
|
100
|
-
.option("--config <config>", "The path to the configuration file")
|
|
101
|
-
.option("--tag <tag>", "The tag to publish to")
|
|
102
|
-
.option("--branch <branch>", "The branch to publish from")
|
|
103
|
-
.action((_str, opts) => {
|
|
104
|
-
return publish({
|
|
105
|
-
branchConfigs: configOpts.publishOptions.branchConfigs,
|
|
106
|
-
packages: configOpts.publishOptions.packages,
|
|
107
|
-
rootDir: configOpts.publishOptions.rootDir,
|
|
108
|
-
branch: opts._optionValues.branch ?? process.env.BRANCH,
|
|
109
|
-
tag: opts._optionValues.tag ?? process.env.TAG,
|
|
110
|
-
ghToken: process.env.GH_TOKEN,
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
program.parseAsync().catch((error) => {
|
|
115
|
-
console.error(error);
|
|
116
|
-
process.exit(1);
|
|
117
|
-
});
|
|
118
|
-
})
|
|
119
|
-
.catch((error) => {
|
|
120
|
-
console.error(error);
|
|
121
|
-
process.exit(1);
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
},
|
|
125
|
-
);
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { program } from "commander";
|
|
4
|
+
import interpret from "interpret";
|
|
5
|
+
import Liftoff from "liftoff";
|
|
6
|
+
import minimist from "minimist";
|
|
7
|
+
import { readFileSync } from "node:fs";
|
|
8
|
+
import { createRequire } from "node:module";
|
|
9
|
+
import { dirname, join } from "node:path";
|
|
10
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
11
|
+
import v8flags from "v8flags";
|
|
12
|
+
import { publish } from "../src/publish/index.js";
|
|
13
|
+
|
|
14
|
+
const args = process.argv.slice(2);
|
|
15
|
+
const argv = minimist(args);
|
|
16
|
+
|
|
17
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
18
|
+
const pkg = JSON.parse(
|
|
19
|
+
readFileSync(join(__dirname, "../package.json"), "utf8"),
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
const require = createRequire(import.meta.url);
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @param {string} [path]
|
|
26
|
+
*/
|
|
27
|
+
async function requireOrImport(path) {
|
|
28
|
+
if (!path) return null;
|
|
29
|
+
try {
|
|
30
|
+
return require(path);
|
|
31
|
+
} catch (e) {
|
|
32
|
+
// @ts-expect-error
|
|
33
|
+
if (e.code === "ERR_REQUIRE_ESM") {
|
|
34
|
+
// This is needed on Windows, because import() fails if providing a Windows file path.
|
|
35
|
+
const url = pathToFileURL(path);
|
|
36
|
+
// @ts-expect-error
|
|
37
|
+
return import(url);
|
|
38
|
+
}
|
|
39
|
+
throw e;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const Config = new Liftoff({
|
|
44
|
+
name: "edifice-config",
|
|
45
|
+
configName: "edifice.config",
|
|
46
|
+
// @ts-expect-error
|
|
47
|
+
extensions: interpret.jsVariants,
|
|
48
|
+
preload: "esbuild-register/dist/node",
|
|
49
|
+
v8flags,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @param {string} [configPath]
|
|
54
|
+
*/
|
|
55
|
+
function checkForConfigFile(configPath) {
|
|
56
|
+
if (configPath) return;
|
|
57
|
+
console.error(
|
|
58
|
+
[
|
|
59
|
+
"No edifice.config.js file found!",
|
|
60
|
+
"This may be because you're not passing the --config or --cwd flags.",
|
|
61
|
+
"If you are passing these flags, check that the path is correct.",
|
|
62
|
+
"Otherwise, you can create a `edifice.config.js` file in your project root.",
|
|
63
|
+
].join("\n"),
|
|
64
|
+
);
|
|
65
|
+
process.exit(1);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
Config.prepare(
|
|
69
|
+
{
|
|
70
|
+
cwd: argv.cwd,
|
|
71
|
+
configPath: argv.config,
|
|
72
|
+
completion: argv.completion,
|
|
73
|
+
},
|
|
74
|
+
(prepEnv) => {
|
|
75
|
+
Config.execute(prepEnv, (env) => {
|
|
76
|
+
requireOrImport(env.configPath)
|
|
77
|
+
.then((configOpts) => {
|
|
78
|
+
program
|
|
79
|
+
.name("@edifice.io/cli")
|
|
80
|
+
.description(
|
|
81
|
+
"Configuration and tools for publishing and maintaining packages",
|
|
82
|
+
)
|
|
83
|
+
.version(pkg.version);
|
|
84
|
+
|
|
85
|
+
if (configOpts) {
|
|
86
|
+
for (const key of Object.keys(configOpts)) {
|
|
87
|
+
program.setOptionValueWithSource(key, configOpts[key], "config");
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
program
|
|
92
|
+
.command("publish")
|
|
93
|
+
.description(
|
|
94
|
+
"Publish your package with the current working directory",
|
|
95
|
+
)
|
|
96
|
+
.option(
|
|
97
|
+
"--cwd <dir>",
|
|
98
|
+
"Current working directory of the configuration file",
|
|
99
|
+
)
|
|
100
|
+
.option("--config <config>", "The path to the configuration file")
|
|
101
|
+
.option("--tag <tag>", "The tag to publish to")
|
|
102
|
+
.option("--branch <branch>", "The branch to publish from")
|
|
103
|
+
.action((_str, opts) => {
|
|
104
|
+
return publish({
|
|
105
|
+
branchConfigs: configOpts.publishOptions.branchConfigs,
|
|
106
|
+
packages: configOpts.publishOptions.packages,
|
|
107
|
+
rootDir: configOpts.publishOptions.rootDir,
|
|
108
|
+
branch: opts._optionValues.branch ?? process.env.BRANCH,
|
|
109
|
+
tag: opts._optionValues.tag ?? process.env.TAG,
|
|
110
|
+
ghToken: process.env.GH_TOKEN,
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
program.parseAsync().catch((error) => {
|
|
115
|
+
console.error(error);
|
|
116
|
+
process.exit(1);
|
|
117
|
+
});
|
|
118
|
+
})
|
|
119
|
+
.catch((error) => {
|
|
120
|
+
console.error(error);
|
|
121
|
+
process.exit(1);
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
},
|
|
125
|
+
);
|
package/package.json
CHANGED
package/src/publish/index.d.ts
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
export type Commit = {
|
|
2
|
-
hash: string;
|
|
3
|
-
body: string;
|
|
4
|
-
subject: string;
|
|
5
|
-
author_name: string;
|
|
6
|
-
author_email: string;
|
|
7
|
-
type: string;
|
|
8
|
-
scope: string | null | undefined;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export type Package = {
|
|
12
|
-
name: string;
|
|
13
|
-
packageDir: string;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export type BranchConfig = {
|
|
17
|
-
prerelease: boolean;
|
|
18
|
-
previousVersion?: boolean;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export type Options = {
|
|
22
|
-
/** Contains config for publishable branches. */
|
|
23
|
-
branchConfigs: Record<string, BranchConfig>;
|
|
24
|
-
/** List your npm packages here. The first package will be used as the versioner. */
|
|
25
|
-
packages: Array<Package>;
|
|
26
|
-
/** Path to root directory of your project. */
|
|
27
|
-
rootDir: string;
|
|
28
|
-
/** The branch to publish. Defaults to the current branch if none supplied. */
|
|
29
|
-
branch?: string;
|
|
30
|
-
/** A manual tag to force release. Must start with `v` */
|
|
31
|
-
tag?: string;
|
|
32
|
-
/** The GitHub token used to search for user metadata and make a GitHub release. */
|
|
33
|
-
ghToken?: string;
|
|
34
|
-
emptyPackageScript?: boolean;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export function publish(options: Options): Promise<void>;
|
|
1
|
+
export type Commit = {
|
|
2
|
+
hash: string;
|
|
3
|
+
body: string;
|
|
4
|
+
subject: string;
|
|
5
|
+
author_name: string;
|
|
6
|
+
author_email: string;
|
|
7
|
+
type: string;
|
|
8
|
+
scope: string | null | undefined;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type Package = {
|
|
12
|
+
name: string;
|
|
13
|
+
packageDir: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type BranchConfig = {
|
|
17
|
+
prerelease: boolean;
|
|
18
|
+
previousVersion?: boolean;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type Options = {
|
|
22
|
+
/** Contains config for publishable branches. */
|
|
23
|
+
branchConfigs: Record<string, BranchConfig>;
|
|
24
|
+
/** List your npm packages here. The first package will be used as the versioner. */
|
|
25
|
+
packages: Array<Package>;
|
|
26
|
+
/** Path to root directory of your project. */
|
|
27
|
+
rootDir: string;
|
|
28
|
+
/** The branch to publish. Defaults to the current branch if none supplied. */
|
|
29
|
+
branch?: string;
|
|
30
|
+
/** A manual tag to force release. Must start with `v` */
|
|
31
|
+
tag?: string;
|
|
32
|
+
/** The GitHub token used to search for user metadata and make a GitHub release. */
|
|
33
|
+
ghToken?: string;
|
|
34
|
+
emptyPackageScript?: boolean;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export function publish(options: Options): Promise<void>;
|