@eik/cli 3.1.9 → 3.1.10
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 +8 -0
- package/classes/version.js +5 -2
- package/commands/publish.js +2 -1
- package/commands/version.js +26 -10
- package/index.js +1 -1
- package/package.json +5 -5
- package/types/classes/version.d.ts +4 -1
- package/types/utils/defaults.d.ts +4 -2
- package/utils/defaults.js +6 -2
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## [3.1.10](https://github.com/eik-lib/cli/compare/v3.1.9...v3.1.10) (2024-10-18)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* output config file name when passed --config ([c078fca](https://github.com/eik-lib/cli/commit/c078fca2bf512f904edf5cb4f9af717f977a3ae9))
|
7
|
+
* support --config for file paths ([07a8924](https://github.com/eik-lib/cli/commit/07a892439e3ff22b69d16c8e3ee93a3dd0332eba))
|
8
|
+
|
1
9
|
## [3.1.9](https://github.com/eik-lib/cli/compare/v3.1.8...v3.1.9) (2024-10-14)
|
2
10
|
|
3
11
|
|
package/classes/version.js
CHANGED
@@ -20,6 +20,7 @@ import { typeSlug } from "../utils/index.js";
|
|
20
20
|
* @property {string[]} [map]
|
21
21
|
* @property {string} [out="./.eik"]
|
22
22
|
* @property {string | Record<string, string>} files
|
23
|
+
* @property {string} [configFile="eik.json"]
|
23
24
|
*/
|
24
25
|
|
25
26
|
export default class Version {
|
@@ -37,6 +38,7 @@ export default class Version {
|
|
37
38
|
map = [],
|
38
39
|
out = "./.eik",
|
39
40
|
files,
|
41
|
+
configFile = "eik.json",
|
40
42
|
}) {
|
41
43
|
const config = new EikConfig(
|
42
44
|
{
|
@@ -54,6 +56,7 @@ export default class Version {
|
|
54
56
|
|
55
57
|
this.log = abslog(logger);
|
56
58
|
this.config = config;
|
59
|
+
this.configFile = configFile;
|
57
60
|
this.path = isAbsolute(config.out) ? config.out : join(cwd, config.out);
|
58
61
|
this.level = level;
|
59
62
|
}
|
@@ -64,7 +67,7 @@ export default class Version {
|
|
64
67
|
*/
|
65
68
|
async run() {
|
66
69
|
const { name, server, type, version, cwd, out, files, map } = this.config;
|
67
|
-
const { log, level, path } = this;
|
70
|
+
const { log, level, path, configFile } = this;
|
68
71
|
log.debug("Validating input");
|
69
72
|
|
70
73
|
log.debug(` ==> config object`);
|
@@ -116,7 +119,7 @@ export default class Version {
|
|
116
119
|
let localHash;
|
117
120
|
try {
|
118
121
|
makeDirectorySync(path);
|
119
|
-
const eikPathDest = join(path,
|
122
|
+
const eikPathDest = join(path, configFile);
|
120
123
|
const eikJSON = {
|
121
124
|
name,
|
122
125
|
server,
|
package/commands/publish.js
CHANGED
@@ -47,6 +47,7 @@ export const handler = commandHandler(
|
|
47
47
|
out,
|
48
48
|
files,
|
49
49
|
type,
|
50
|
+
configFile,
|
50
51
|
} = argv;
|
51
52
|
|
52
53
|
if (type === "map") {
|
@@ -76,7 +77,7 @@ export const handler = commandHandler(
|
|
76
77
|
if (!publish) {
|
77
78
|
throw new EikCliError(
|
78
79
|
errors.ERR_VERSION_EXISTS,
|
79
|
-
|
80
|
+
`Version in ${configFile} has not changed since last publish, publishing is not necessary`,
|
80
81
|
);
|
81
82
|
}
|
82
83
|
|
package/commands/version.js
CHANGED
@@ -34,7 +34,18 @@ export const builder = (yargs) => {
|
|
34
34
|
export const handler = commandHandler(
|
35
35
|
{ command, options: ["server"] },
|
36
36
|
async (argv, log) => {
|
37
|
-
const {
|
37
|
+
const {
|
38
|
+
level,
|
39
|
+
dryRun,
|
40
|
+
cwd,
|
41
|
+
name,
|
42
|
+
version,
|
43
|
+
server,
|
44
|
+
map,
|
45
|
+
out,
|
46
|
+
files,
|
47
|
+
configFile,
|
48
|
+
} = argv;
|
38
49
|
|
39
50
|
const options = {
|
40
51
|
logger: log,
|
@@ -46,6 +57,7 @@ export const handler = commandHandler(
|
|
46
57
|
map,
|
47
58
|
out,
|
48
59
|
files,
|
60
|
+
configFile,
|
49
61
|
};
|
50
62
|
|
51
63
|
const newVersion = await new VersionPackage(options).run();
|
@@ -55,26 +67,30 @@ export const handler = commandHandler(
|
|
55
67
|
`Dry Run: new version needed, determined new version to be ${newVersion}`,
|
56
68
|
);
|
57
69
|
} else {
|
58
|
-
log.debug(`Writing new version ${newVersion} to
|
70
|
+
log.debug(`Writing new version ${newVersion} to ${configFile}`);
|
59
71
|
// @ts-expect-error
|
60
|
-
await json.writeEik(
|
72
|
+
await json.writeEik(
|
73
|
+
{ version: newVersion },
|
74
|
+
{ cwd, filename: configFile },
|
75
|
+
);
|
61
76
|
|
62
|
-
log.debug(`Committing
|
77
|
+
log.debug(`Committing ${configFile} to local git repository`);
|
63
78
|
try {
|
64
|
-
execSync(`git add ${
|
65
|
-
log.debug(` ==> stage: ${join(cwd,
|
79
|
+
execSync(`git add ${configFile}`, { cwd });
|
80
|
+
log.debug(` ==> stage: ${join(cwd, configFile)}`);
|
66
81
|
} catch (err) {
|
67
82
|
throw new EikCliError(
|
68
83
|
errors.ERR_NOT_GIT,
|
69
|
-
|
84
|
+
`Failed to stage file "${configFile}". Is this directory (or any parent directories) a git repository?`,
|
70
85
|
err,
|
71
86
|
);
|
72
87
|
}
|
73
88
|
|
74
89
|
try {
|
75
90
|
execSync(
|
76
|
-
`git commit -m "build(assets): version
|
91
|
+
`git commit -m "build(assets): version ${configFile} to v${newVersion} [skip ci]"`,
|
77
92
|
{
|
93
|
+
cwd,
|
78
94
|
env: {
|
79
95
|
GIT_AUTHOR_NAME: "Eik Cli",
|
80
96
|
GIT_AUTHOR_EMAIL: "eik@eik.dev",
|
@@ -86,11 +102,11 @@ export const handler = commandHandler(
|
|
86
102
|
);
|
87
103
|
log.debug(` ==> commit`);
|
88
104
|
|
89
|
-
log.info(`New version ${newVersion} written back to
|
105
|
+
log.info(`New version ${newVersion} written back to ${configFile}`);
|
90
106
|
} catch (err) {
|
91
107
|
throw new EikCliError(
|
92
108
|
errors.ERR_GIT_COMMIT,
|
93
|
-
|
109
|
+
`Failed to commit changes to file "${configFile}".`,
|
94
110
|
err,
|
95
111
|
);
|
96
112
|
}
|
package/index.js
CHANGED
@@ -56,7 +56,7 @@ For a more detailed description of commands and options, see the reference docum
|
|
56
56
|
.options({
|
57
57
|
config: {
|
58
58
|
alias: "c",
|
59
|
-
describe: "Path to Eik configuration file
|
59
|
+
describe: "Path to Eik configuration file",
|
60
60
|
},
|
61
61
|
cwd: {
|
62
62
|
describe: "Path to a different working directory than the current",
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@eik/cli",
|
3
|
-
"version": "3.1.
|
3
|
+
"version": "3.1.10",
|
4
4
|
"description": "CLI tool for publishing assets to an Eik server",
|
5
5
|
"main": "./classes/index.js",
|
6
6
|
"types": "./types/classes/index.d.ts",
|
@@ -21,10 +21,10 @@
|
|
21
21
|
],
|
22
22
|
"scripts": {
|
23
23
|
"clean": "rimraf .tap node_modules types",
|
24
|
-
"test": "cross-env HTTP_PORT=0 LOG_LEVEL=fatal tap --timeout
|
25
|
-
"test:integration": "cross-env HTTP_PORT=0 LOG_LEVEL=fatal tap --timeout
|
26
|
-
"test:unit": "cross-env HTTP_PORT=0 LOG_LEVEL=fatal tap --timeout
|
27
|
-
"test:tasks": "cross-env HTTP_PORT=0 LOG_LEVEL=fatal tap --timeout
|
24
|
+
"test": "cross-env HTTP_PORT=0 LOG_LEVEL=fatal tap --timeout 60 --disable-coverage",
|
25
|
+
"test:integration": "cross-env HTTP_PORT=0 LOG_LEVEL=fatal tap --timeout 60 --disable-coverage test/integration/**/*.test.mjs",
|
26
|
+
"test:unit": "cross-env HTTP_PORT=0 LOG_LEVEL=fatal tap --timeout 60 --disable-coverage test/*.test.mjs",
|
27
|
+
"test:tasks": "cross-env HTTP_PORT=0 LOG_LEVEL=fatal tap --timeout 60 --disable-coverage test/tasks/*.test.mjs",
|
28
28
|
"lint": "eslint .",
|
29
29
|
"lint:fix": "eslint --fix .",
|
30
30
|
"format:check": "prettier -c .",
|
@@ -10,14 +10,16 @@
|
|
10
10
|
* @property {string[]} [map]
|
11
11
|
* @property {string} [out="./.eik"]
|
12
12
|
* @property {string | Record<string, string>} files
|
13
|
+
* @property {string} [configFile="eik.json"]
|
13
14
|
*/
|
14
15
|
export default class Version {
|
15
16
|
/**
|
16
17
|
* @param {VersionOptions} options
|
17
18
|
*/
|
18
|
-
constructor({ logger, server, type, name, version, level, cwd, map, out, files, }: VersionOptions);
|
19
|
+
constructor({ logger, server, type, name, version, level, cwd, map, out, files, configFile, }: VersionOptions);
|
19
20
|
log: abslog.ValidLogger;
|
20
21
|
config: EikConfig;
|
22
|
+
configFile: string;
|
21
23
|
path: string;
|
22
24
|
level: semver.ReleaseType;
|
23
25
|
/**
|
@@ -37,6 +39,7 @@ export type VersionOptions = {
|
|
37
39
|
map?: string[];
|
38
40
|
out?: string;
|
39
41
|
files: string | Record<string, string>;
|
42
|
+
configFile?: string;
|
40
43
|
};
|
41
44
|
import abslog from "abslog";
|
42
45
|
import { EikConfig } from "@eik/common";
|
@@ -4,12 +4,14 @@
|
|
4
4
|
* @template [T=Record<string, unknown>]
|
5
5
|
* @param {any} argv
|
6
6
|
* @param {{ command: string; options?: string[] }} opts
|
7
|
-
* @returns {import('@eik/common').EikConfig & typeof defaults & T}
|
7
|
+
* @returns {import('@eik/common').EikConfig & typeof defaults & { configFile: string } & T}
|
8
8
|
*/
|
9
9
|
export function getArgsOrDefaults<T = Record<string, unknown>>(argv: any, opts: {
|
10
10
|
command: string;
|
11
11
|
options?: string[];
|
12
|
-
}): import("@eik/common").EikConfig & typeof defaults &
|
12
|
+
}): import("@eik/common").EikConfig & typeof defaults & {
|
13
|
+
configFile: string;
|
14
|
+
} & T;
|
13
15
|
declare const defaults: {
|
14
16
|
name: string;
|
15
17
|
type: string;
|
package/utils/defaults.js
CHANGED
@@ -19,7 +19,7 @@ const defaults = {
|
|
19
19
|
* @template [T=Record<string, unknown>]
|
20
20
|
* @param {any} argv
|
21
21
|
* @param {{ command: string; options?: string[] }} opts
|
22
|
-
* @returns {import('@eik/common').EikConfig & typeof defaults & T}
|
22
|
+
* @returns {import('@eik/common').EikConfig & typeof defaults & { configFile: string } & T}
|
23
23
|
*/
|
24
24
|
export function getArgsOrDefaults(argv, opts) {
|
25
25
|
let { cwd, config: configPath } = argv;
|
@@ -27,7 +27,9 @@ export function getArgsOrDefaults(argv, opts) {
|
|
27
27
|
cwd = process.cwd();
|
28
28
|
}
|
29
29
|
|
30
|
-
let config = {
|
30
|
+
let config = {
|
31
|
+
configFile: "eik.json",
|
32
|
+
};
|
31
33
|
if (!opts.command.startsWith("init")) {
|
32
34
|
let path = cwd;
|
33
35
|
if (configPath) {
|
@@ -41,8 +43,10 @@ export function getArgsOrDefaults(argv, opts) {
|
|
41
43
|
eikConfig = helpers.configStore.findInDirectory(path);
|
42
44
|
} else {
|
43
45
|
eikConfig = helpers.configStore.loadFromPath(path);
|
46
|
+
config.configFile = configPath;
|
44
47
|
}
|
45
48
|
config = {
|
49
|
+
...config,
|
46
50
|
name: eikConfig.name,
|
47
51
|
version: eikConfig.version,
|
48
52
|
type: eikConfig.type,
|