@eik/cli 3.1.3 → 3.1.5
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 +14 -0
- package/classes/alias.js +109 -119
- package/classes/index.js +58 -58
- package/classes/integrity.js +89 -97
- package/classes/login.js +47 -47
- package/classes/meta.js +75 -80
- package/classes/ping.js +53 -53
- package/classes/publish/map.js +90 -92
- package/classes/publish/package/index.js +130 -130
- package/classes/publish/package/tasks/check-bundle-sizes.js +19 -21
- package/classes/publish/package/tasks/check-if-already-published.js +67 -72
- package/classes/publish/package/tasks/cleanup.js +17 -17
- package/classes/publish/package/tasks/create-temp-directory.js +17 -17
- package/classes/publish/package/tasks/create-zip-file.js +60 -65
- package/classes/publish/package/tasks/dry-run.js +15 -15
- package/classes/publish/package/tasks/save-metafile.js +17 -17
- package/classes/publish/package/tasks/task.js +7 -7
- package/classes/publish/package/tasks/upload-files.js +52 -56
- package/classes/publish/package/tasks/validate-input.js +24 -24
- package/classes/version.js +152 -163
- package/commands/alias.js +61 -95
- package/commands/init.js +89 -109
- package/commands/integrity.js +42 -55
- package/commands/login.js +80 -101
- package/commands/map-alias.js +62 -82
- package/commands/map.js +69 -83
- package/commands/meta.js +36 -53
- package/commands/npm-alias.js +55 -80
- package/commands/package-alias.js +58 -90
- package/commands/ping.js +19 -30
- package/commands/publish.js +117 -127
- package/commands/version.js +87 -95
- package/formatters/alias.js +60 -63
- package/formatters/artifact.js +77 -77
- package/formatters/file.js +25 -25
- package/formatters/index.js +4 -4
- package/formatters/version.js +49 -51
- package/index.js +76 -72
- package/package.json +5 -4
- package/readme.md +1 -1
- package/types/classes/alias.d.ts +3 -3
- package/types/classes/integrity.d.ts +1 -1
- package/types/classes/login.d.ts +1 -1
- package/types/classes/meta.d.ts +1 -1
- package/types/classes/ping.d.ts +1 -1
- package/types/classes/publish/map.d.ts +1 -1
- package/types/classes/publish/package/index.d.ts +11 -11
- package/types/classes/publish/package/tasks/check-bundle-sizes.d.ts +1 -1
- package/types/classes/publish/package/tasks/check-if-already-published.d.ts +1 -1
- package/types/classes/publish/package/tasks/cleanup.d.ts +1 -1
- package/types/classes/publish/package/tasks/create-temp-directory.d.ts +1 -1
- package/types/classes/publish/package/tasks/create-zip-file.d.ts +1 -1
- package/types/classes/publish/package/tasks/dry-run.d.ts +1 -1
- package/types/classes/publish/package/tasks/save-metafile.d.ts +1 -1
- package/types/classes/publish/package/tasks/task.d.ts +1 -1
- package/types/classes/publish/package/tasks/upload-files.d.ts +1 -1
- package/types/classes/publish/package/tasks/validate-input.d.ts +1 -1
- package/types/classes/version.d.ts +3 -3
- package/types/utils/defaults.d.ts +22 -0
- package/types/utils/error.d.ts +19 -0
- package/types/utils/hash/index.d.ts +3 -3
- package/types/utils/http/index.d.ts +4 -4
- package/types/utils/index.d.ts +5 -5
- package/types/utils/json/index.d.ts +3 -3
- package/utils/command-handler.js +72 -0
- package/utils/defaults.js +79 -0
- package/utils/error.js +42 -0
- package/utils/hash/file.js +4 -4
- package/utils/hash/files.js +9 -9
- package/utils/hash/index.js +3 -3
- package/utils/http/index.js +4 -4
- package/utils/http/integrity.js +18 -18
- package/utils/http/latest-version.js +37 -37
- package/utils/http/request.js +42 -42
- package/utils/http/versions.js +20 -20
- package/utils/index.js +6 -5
- package/utils/json/index.js +3 -3
- package/utils/json/read.js +26 -26
- package/utils/json/write-eik.js +17 -17
- package/utils/json/write.js +26 -28
- package/utils/logger.js +43 -43
- package/utils/type-title.js +3 -3
- package/utils/url.js +2 -2
- package/commands/index.js +0 -27
package/utils/json/write-eik.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import fs from
|
2
|
-
import { join } from
|
1
|
+
import fs from "node:fs/promises";
|
2
|
+
import { join } from "path";
|
3
3
|
|
4
4
|
/**
|
5
5
|
* Reads, updates and then writes data to given eik.json file (defaults to file in current directory)
|
@@ -14,20 +14,20 @@ import { join } from 'path';
|
|
14
14
|
* @example json.writeEik({ key: 'value' }, { cwd: '/path/to/cwd', filename: 'eik.json' });
|
15
15
|
*/
|
16
16
|
export default async (data = {}, options) => {
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
const { cwd = process.cwd(), filename = "eik.json" } = options;
|
18
|
+
const eikpath = join(cwd, filename);
|
19
|
+
const eik = await fs.readFile(eikpath, "utf-8");
|
20
|
+
const eikjson = JSON.parse(eik);
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
22
|
+
await fs.writeFile(
|
23
|
+
eikpath,
|
24
|
+
JSON.stringify(
|
25
|
+
{
|
26
|
+
...eikjson,
|
27
|
+
...data,
|
28
|
+
},
|
29
|
+
null,
|
30
|
+
2,
|
31
|
+
),
|
32
|
+
);
|
33
33
|
};
|
package/utils/json/write.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
import assert from
|
2
|
-
import fs from
|
3
|
-
import { join, isAbsolute, dirname } from
|
1
|
+
import assert from "assert";
|
2
|
+
import fs from "node:fs/promises";
|
3
|
+
import { join, isAbsolute, dirname } from "path";
|
4
4
|
|
5
5
|
/**
|
6
6
|
* Utility function that can be used to write a JavaScript object to a file at a given location.
|
@@ -20,29 +20,27 @@ import { join, isAbsolute, dirname } from 'path';
|
|
20
20
|
* @throws Error
|
21
21
|
*/
|
22
22
|
export default async (meta = {}, location) => {
|
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
|
-
}
|
23
|
+
if (typeof location !== "string") {
|
24
|
+
assert(
|
25
|
+
location.filename,
|
26
|
+
'When "location" is not of type "string" then it must be an "object" with property "filename"',
|
27
|
+
);
|
28
|
+
}
|
29
|
+
let cwd = process.cwd();
|
30
|
+
let filename = "";
|
31
|
+
if (typeof location === "string") {
|
32
|
+
filename = location;
|
33
|
+
} else {
|
34
|
+
filename = location.filename;
|
35
|
+
if (location.cwd) {
|
36
|
+
cwd = location.cwd;
|
37
|
+
}
|
38
|
+
}
|
39
|
+
const path = isAbsolute(filename) ? filename : join(cwd, filename);
|
40
|
+
try {
|
41
|
+
await fs.mkdir(dirname(path), { recursive: true });
|
42
|
+
await fs.writeFile(path, JSON.stringify(meta, null, 2));
|
43
|
+
} catch (err) {
|
44
|
+
throw new Error(`Error writing to JSON file ["${path}"]: ${err.message}`);
|
45
|
+
}
|
48
46
|
};
|
package/utils/logger.js
CHANGED
@@ -5,50 +5,50 @@
|
|
5
5
|
* @param {boolean} debug
|
6
6
|
*/
|
7
7
|
const logger = (spinner, debug = false) => ({
|
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
|
-
|
8
|
+
/**
|
9
|
+
* @param {string} message
|
10
|
+
*/
|
11
|
+
fatal(message) {
|
12
|
+
spinner.fail(message).start();
|
13
|
+
},
|
14
|
+
/**
|
15
|
+
* @param {string} message
|
16
|
+
*/
|
17
|
+
error(message) {
|
18
|
+
spinner.fail(message).start();
|
19
|
+
},
|
20
|
+
/**
|
21
|
+
* @param {string} message
|
22
|
+
*/
|
23
|
+
warn(message) {
|
24
|
+
spinner.warn(message).start();
|
25
|
+
},
|
26
|
+
/**
|
27
|
+
* @param {string} message
|
28
|
+
*/
|
29
|
+
info(message) {
|
30
|
+
if (typeof message !== "string") {
|
31
|
+
spinner.text = "";
|
32
|
+
spinner.stopAndPersist();
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
34
|
+
console.log(message);
|
35
|
+
spinner.start();
|
36
|
+
} else {
|
37
|
+
spinner.succeed(message).start();
|
38
|
+
}
|
39
|
+
},
|
40
|
+
/**
|
41
|
+
* @param {string} message
|
42
|
+
*/
|
43
|
+
debug(message) {
|
44
|
+
if (debug) spinner.info(message).start();
|
45
|
+
},
|
46
|
+
/**
|
47
|
+
* @param {string} message
|
48
|
+
*/
|
49
|
+
trace(message) {
|
50
|
+
if (debug) spinner.info(message).start();
|
51
|
+
},
|
52
52
|
});
|
53
53
|
|
54
54
|
export default logger;
|
package/utils/type-title.js
CHANGED
package/utils/url.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { join } from
|
1
|
+
import { join } from "node:path";
|
2
2
|
|
3
3
|
/**
|
4
4
|
* A version of path.join that replaces \ (win32) with /
|
@@ -6,5 +6,5 @@ import { join } from 'node:path';
|
|
6
6
|
* @returns {string}
|
7
7
|
*/
|
8
8
|
export function joinUrlPathname(...parts) {
|
9
|
-
|
9
|
+
return join(...parts).replace(/\\/g, "/");
|
10
10
|
}
|
package/commands/index.js
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
import * as init from './init.js';
|
2
|
-
import * as integrity from './integrity.js';
|
3
|
-
import * as login from './login.js';
|
4
|
-
import * as mapAlias from './map-alias.js';
|
5
|
-
import * as map from './map.js';
|
6
|
-
import * as meta from './meta.js';
|
7
|
-
import * as npmAlias from './npm-alias.js';
|
8
|
-
import * as packageAlias from './package-alias.js';
|
9
|
-
import * as ping from './ping.js';
|
10
|
-
import * as publish from './publish.js';
|
11
|
-
import * as version from './version.js';
|
12
|
-
import * as alias from './alias.js';
|
13
|
-
|
14
|
-
export const commands = [
|
15
|
-
init,
|
16
|
-
integrity,
|
17
|
-
login,
|
18
|
-
mapAlias,
|
19
|
-
map,
|
20
|
-
meta,
|
21
|
-
npmAlias,
|
22
|
-
packageAlias,
|
23
|
-
ping,
|
24
|
-
publish,
|
25
|
-
version,
|
26
|
-
alias,
|
27
|
-
];
|