@eik/cli 3.1.17 → 3.1.19

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.
Files changed (53) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/classes/alias.js +10 -8
  3. package/classes/index.js +4 -2
  4. package/classes/integrity.js +9 -12
  5. package/classes/login.js +5 -7
  6. package/classes/meta.js +3 -2
  7. package/classes/ping.js +2 -2
  8. package/classes/publish/map.js +5 -5
  9. package/classes/publish/package/{index.js → publish.js} +1 -1
  10. package/classes/publish/package/tasks/check-if-already-published.js +7 -5
  11. package/classes/publish/package/tasks/create-temp-directory.js +2 -2
  12. package/classes/publish/package/tasks/save-metafile.js +2 -2
  13. package/classes/publish/package/tasks/upload-files.js +2 -2
  14. package/classes/version.js +28 -30
  15. package/commands/alias.js +1 -1
  16. package/commands/integrity.js +2 -2
  17. package/commands/login.js +4 -3
  18. package/commands/map-alias.js +1 -1
  19. package/commands/map.js +1 -1
  20. package/commands/meta.js +1 -1
  21. package/commands/npm-alias.js +1 -1
  22. package/commands/package-alias.js +1 -1
  23. package/commands/publish.js +11 -12
  24. package/commands/version.js +2 -6
  25. package/formatters/alias.js +15 -15
  26. package/formatters/artifact.js +9 -9
  27. package/formatters/file.js +5 -5
  28. package/formatters/version.js +7 -7
  29. package/package.json +4 -6
  30. package/types/classes/alias.d.ts +1 -1
  31. package/types/classes/index.d.ts +2 -2
  32. package/types/classes/version.d.ts +2 -3
  33. package/utils/defaults.js +3 -3
  34. package/utils/hash/file.js +8 -4
  35. package/utils/hash/files.js +5 -4
  36. package/utils/http/integrity.js +1 -1
  37. package/formatters/index.js +0 -6
  38. package/types/utils/defaults.d.ts +0 -24
  39. package/types/utils/error.d.ts +0 -19
  40. package/types/utils/hash/index.d.ts +0 -9
  41. package/types/utils/http/index.d.ts +0 -12
  42. package/types/utils/http/latest-version.d.ts +0 -2
  43. package/types/utils/index.d.ts +0 -6
  44. package/types/utils/json/index.d.ts +0 -9
  45. package/types/utils/json/read.d.ts +0 -5
  46. package/types/utils/json/write-eik.d.ts +0 -5
  47. package/types/utils/logger.d.ts +0 -33
  48. package/types/utils/type-title.d.ts +0 -2
  49. package/utils/hash/index.js +0 -5
  50. package/utils/http/index.js +0 -7
  51. package/utils/index.js +0 -8
  52. package/utils/json/index.js +0 -5
  53. /package/types/classes/publish/package/{index.d.ts → publish.d.ts} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ ## [3.1.19](https://github.com/eik-lib/cli/compare/v3.1.18...v3.1.19) (2025-07-01)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deps:** update dependency @eik/common to v5.1.5 ([#613](https://github.com/eik-lib/cli/issues/613)) ([5d02a55](https://github.com/eik-lib/cli/commit/5d02a55da161b32cb9448cd4a359f6f8e07c3029))
7
+
8
+ ## [3.1.18](https://github.com/eik-lib/cli/compare/v3.1.17...v3.1.18) (2025-06-12)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * recreate subdirectories when comparing hash ([d07baf7](https://github.com/eik-lib/cli/commit/d07baf763ac718c3677b069513297f591c6f11c0))
14
+ * upgrade eik/common ([924c26c](https://github.com/eik-lib/cli/commit/924c26ca50ff84198b7bf8e944565d995c03f7ac))
15
+
1
16
  ## [3.1.17](https://github.com/eik-lib/cli/compare/v3.1.16...v3.1.17) (2025-06-09)
2
17
 
3
18
 
package/classes/alias.js CHANGED
@@ -1,8 +1,10 @@
1
1
  import assert from "assert";
2
2
  import abslog from "abslog";
3
- import { schemas, validators } from "@eik/common";
4
- import { request } from "../utils/http/index.js";
5
- import { typeSlug } from "../utils/index.js";
3
+ import schemasAssert from "@eik/common/lib/schemas/assert.js";
4
+ import { type as validateType } from "@eik/common/lib/validators/type.js";
5
+ import { alias as validateAlias } from "@eik/common/lib/validators/alias.js";
6
+ import request from "../utils/http/request.js";
7
+ import typeSlug from "@eik/common/lib/helpers/type-slug.js";
6
8
  import { joinUrlPathname } from "../utils/url.js";
7
9
 
8
10
  /**
@@ -60,11 +62,11 @@ export default class Alias {
60
62
  };
61
63
 
62
64
  this.log.debug("Validating command input");
63
- schemas.assert.server(this.server);
64
- schemas.assert.name(this.name);
65
- schemas.assert.version(this.version);
66
- validators.type(this.type);
67
- validators.alias(this.alias);
65
+ schemasAssert.server(this.server);
66
+ schemasAssert.name(this.name);
67
+ schemasAssert.version(this.version);
68
+ validateType(this.type);
69
+ validateAlias(this.alias);
68
70
  assert(
69
71
  this.token && typeof this.token === "string",
70
72
  `Parameter "token" is not valid`,
package/classes/index.js CHANGED
@@ -3,10 +3,12 @@ import Alias from "./alias.js";
3
3
  import Meta from "./meta.js";
4
4
  import Login from "./login.js";
5
5
  import PublishMap from "./publish/map.js";
6
- import PublishPackage from "./publish/package/index.js";
6
+ import PublishPackage from "./publish/package/publish.js";
7
7
  import Integrity from "./integrity.js";
8
8
  import Version from "./version.js";
9
9
 
10
+ // TODO: remove this in the next major version of the module, point people to the classes directly
11
+
10
12
  export default {
11
13
  /**
12
14
  * @param {import('./alias.js').AliasOptions} opts
@@ -53,7 +55,7 @@ export default {
53
55
  },
54
56
 
55
57
  /**
56
- * @param {import('./publish/package/index.js').PublishOptions} opts
58
+ * @param {import('./publish/package/publish.js').PublishOptions} opts
57
59
  */
58
60
  publish(opts) {
59
61
  return new PublishPackage(opts).run();
@@ -1,10 +1,9 @@
1
1
  import abslog from "abslog";
2
- import eik from "@eik/common";
3
- import { typeSlug } from "../utils/index.js";
2
+ import assert from "@eik/common/lib/schemas/assert.js";
3
+ import ValidationError from "@eik/common/lib/schemas/validation-error.js";
4
+ import typeSlug from "@eik/common/lib/helpers/type-slug.js";
4
5
  import { joinUrlPathname } from "../utils/url.js";
5
6
 
6
- const { schemas } = eik;
7
-
8
7
  /**
9
8
  * @typedef {object} IntegrityOptions
10
9
  * @property {import('abslog').AbstractLoggerOptions} [logger]
@@ -44,27 +43,25 @@ export default class Integrity {
44
43
 
45
44
  try {
46
45
  this.log.debug(` ==> server: ${this.server}`);
47
- schemas.assert.server(this.server);
46
+ assert.server(this.server);
48
47
 
49
48
  this.log.debug(` ==> name: ${this.name}`);
50
- schemas.assert.name(this.name);
49
+ assert.name(this.name);
51
50
 
52
51
  this.log.debug(` ==> version: ${this.version}`);
53
- schemas.assert.version(this.version);
52
+ assert.version(this.version);
54
53
 
55
54
  this.log.debug(` ==> type: ${this.type}`);
56
- schemas.assert.type(this.type || null);
55
+ assert.type(this.type || null);
57
56
 
58
57
  this.log.debug(` ==> debug: ${this.debug}`);
59
58
  if (typeof this.debug !== "boolean") {
60
- // @ts-expect-error
61
- throw new schemas.ValidationError(`Parameter "debug" is not valid`);
59
+ throw new ValidationError(`Parameter "debug" is not valid`);
62
60
  }
63
61
 
64
62
  this.log.debug(` ==> cwd: ${this.cwd}`);
65
63
  if (typeof this.cwd !== "string") {
66
- // @ts-expect-error
67
- throw new schemas.ValidationError(`Parameter "cwd" is not valid`);
64
+ throw new ValidationError(`Parameter "cwd" is not valid`);
68
65
  }
69
66
  } catch (err) {
70
67
  throw new Error(`Unable to validate input to command: ${err.message}`);
package/classes/login.js CHANGED
@@ -1,8 +1,7 @@
1
1
  import abslog from "abslog";
2
- import eik from "@eik/common";
3
- import { request } from "../utils/http/index.js";
4
-
5
- const { schemas } = eik;
2
+ import assert from "@eik/common/lib/schemas/assert.js";
3
+ import ValidationError from "@eik/common/lib/schemas/validation-error.js";
4
+ import request from "../utils/http/request.js";
6
5
 
7
6
  /**
8
7
  * @typedef {object} LoginOptions
@@ -28,10 +27,9 @@ export default class Login {
28
27
  this.log.debug("Validating input");
29
28
 
30
29
  try {
31
- schemas.assert.server(this.server);
30
+ assert.server(this.server);
32
31
  if (!this.key || typeof !this.key === "string") {
33
- // @ts-expect-error
34
- throw new schemas.ValidationError('"key" must be a string');
32
+ throw new ValidationError('"key" must be a string');
35
33
  }
36
34
  } catch (err) {
37
35
  this.log.error(err.message);
package/classes/meta.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import abslog from "abslog";
2
- import { schemas } from "@eik/common";
2
+ import assert from "@eik/common/lib/schemas/assert.js";
3
+
3
4
  import { joinUrlPathname } from "../utils/url.js";
4
5
 
5
6
  const types = ["pkg", "map", "npm"];
@@ -30,7 +31,7 @@ export default class Meta {
30
31
  this.log.debug("Validating input");
31
32
 
32
33
  try {
33
- schemas.assert.server(this.server);
34
+ assert.server(this.server);
34
35
  } catch (err) {
35
36
  this.log.error(err.message);
36
37
  return false;
package/classes/ping.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import abslog from "abslog";
2
- import { schemas } from "@eik/common";
2
+ import assert from "@eik/common/lib/schemas/assert.js";
3
3
 
4
4
  /**
5
5
  * @typedef {object} PingOptions
@@ -24,7 +24,7 @@ export default class Ping {
24
24
  this.log.debug("Validating input");
25
25
 
26
26
  try {
27
- schemas.assert.server(this.server);
27
+ assert.server(this.server);
28
28
  } catch (err) {
29
29
  this.log.error(err.message);
30
30
  return false;
@@ -2,8 +2,8 @@ import assert from "assert";
2
2
  import abslog from "abslog";
3
3
  import { join, parse, isAbsolute } from "path";
4
4
  import { existsSync } from "fs";
5
- import { schemas } from "@eik/common";
6
- import { request } from "../../utils/http/index.js";
5
+ import schemasAssert from "@eik/common/lib/schemas/assert.js";
6
+ import request from "../../utils/http/request.js";
7
7
  import { joinUrlPathname } from "../../utils/url.js";
8
8
 
9
9
  /**
@@ -55,13 +55,13 @@ export default class PublishMap {
55
55
 
56
56
  this.log.debug("Validating input");
57
57
  parse(this.cwd);
58
- schemas.assert.server(this.server);
58
+ schemasAssert.server(this.server);
59
59
  assert(
60
60
  this.token && typeof this.token === "string",
61
61
  'Parameter "token" is not valid',
62
62
  );
63
- schemas.assert.name(this.name);
64
- schemas.assert.version(this.version);
63
+ schemasAssert.name(this.name);
64
+ schemasAssert.version(this.version);
65
65
  parse(this.file);
66
66
 
67
67
  this.absoluteFile = isAbsolute(this.file)
@@ -1,7 +1,7 @@
1
1
  import abslog from "abslog";
2
2
  import { join, isAbsolute } from "path";
3
3
  import { EikConfig } from "@eik/common";
4
- import { typeSlug } from "../../../utils/index.js";
4
+ import typeSlug from "@eik/common/lib/helpers/type-slug.js";
5
5
  import ValidateInput from "./tasks/validate-input.js";
6
6
  import CreateTempDirectory from "./tasks/create-temp-directory.js";
7
7
  import CreateZipFile from "./tasks/create-zip-file.js";
@@ -1,7 +1,9 @@
1
1
  import { join } from "path";
2
- import { integrity, versions } from "../../../../utils/http/index.js";
3
- import hash from "../../../../utils/hash/index.js";
4
- import { typeSlug } from "../../../../utils/index.js";
2
+ import integrity from "../../../../utils/http/integrity.js";
3
+ import versions from "../../../../utils/http/versions.js";
4
+ import hashFiles from "../../../../utils/hash/files.js";
5
+ import hashCompare from "../../../../utils/hash/compare.js";
6
+ import typeSlug from "@eik/common/lib/helpers/type-slug.js";
5
7
  import Task from "./task.js";
6
8
 
7
9
  export default class CheckIfAlreadyPublished extends Task {
@@ -53,7 +55,7 @@ export default class CheckIfAlreadyPublished extends Task {
53
55
  localFiles.push(destination);
54
56
  }
55
57
  }
56
- localHash = await hash.files(localFiles);
58
+ localHash = await hashFiles(localFiles);
57
59
  } catch (err) {
58
60
  throw new Error(
59
61
  `Unable to hash local files for comparison: ${err.message}`,
@@ -63,7 +65,7 @@ export default class CheckIfAlreadyPublished extends Task {
63
65
  // @ts-expect-error
64
66
  const versionMap = new Map(pkgVersions);
65
67
  for (const v of versionMap.values()) {
66
- const same = hash.compare(v.integrity, localHash);
68
+ const same = hashCompare(v.integrity, localHash);
67
69
  if (same) {
68
70
  throw new Error(
69
71
  `Version ${v.version} of this package already contains these files, publishing is not necessary.`,
@@ -1,4 +1,4 @@
1
- import { makeDirectorySync } from "make-dir";
1
+ import { mkdirSync } from "fs";
2
2
  import Task from "./task.js";
3
3
 
4
4
  class IOError extends Error {
@@ -17,7 +17,7 @@ export default class CreateTempDir extends Task {
17
17
  log.debug(` ==> ${path}`);
18
18
 
19
19
  try {
20
- makeDirectorySync(path);
20
+ mkdirSync(path, { recursive: true });
21
21
  } catch (err) {
22
22
  throw new IOError("Unable to create temp dir", err);
23
23
  }
@@ -1,5 +1,5 @@
1
1
  import { join } from "path";
2
- import json from "../../../../utils/json/index.js";
2
+ import write from "../../../../utils/json/write.js";
3
3
  import Task from "./task.js";
4
4
 
5
5
  export default class SaveMetaFile extends Task {
@@ -10,7 +10,7 @@ export default class SaveMetaFile extends Task {
10
10
  log.debug("Saving integrity file");
11
11
  log.debug(` ==> ${filepath}`);
12
12
  try {
13
- await json.write(response, { cwd, filename: filepath });
13
+ await write(response, { cwd, filename: filepath });
14
14
  } catch (err) {
15
15
  throw new Error(
16
16
  `Unable to save integrity file [${filepath}]: ${err.message}`,
@@ -1,5 +1,5 @@
1
- import { request } from "../../../../utils/http/index.js";
2
- import { typeSlug } from "../../../../utils/index.js";
1
+ import request from "../../../../utils/http/request.js";
2
+ import typeSlug from "@eik/common/lib/helpers/type-slug.js";
3
3
  import { joinUrlPathname } from "../../../../utils/url.js";
4
4
 
5
5
  import Task from "./task.js";
@@ -1,12 +1,14 @@
1
- import { copyFileSync, writeFileSync } from "fs";
2
- import { join, isAbsolute, parse } from "path";
1
+ import { copyFileSync, writeFileSync, mkdirSync } from "node:fs";
2
+ import { join, isAbsolute, parse, normalize } from "node:path";
3
3
  import abslog from "abslog";
4
- import semver from "semver";
5
- import { makeDirectorySync } from "make-dir";
6
- import { schemas, EikConfig } from "@eik/common";
7
- import { integrity } from "../utils/http/index.js";
8
- import hash from "../utils/hash/index.js";
9
- import { typeSlug } from "../utils/index.js";
4
+ import inc from "semver/functions/inc.js";
5
+ import EikConfig from "@eik/common/lib/classes/eik-config.js";
6
+ import ValidationError from "@eik/common/lib/schemas/validation-error.js";
7
+ import typeSlug from "@eik/common/lib/helpers/type-slug.js";
8
+ import integrity from "../utils/http/integrity.js";
9
+ import hashFile from "../utils/hash/file.js";
10
+ import hashFiles from "../utils/hash/files.js";
11
+ import hashCompare from "../utils/hash/compare.js";
10
12
 
11
13
  /**
12
14
  * @typedef {object} VersionOptions
@@ -78,20 +80,17 @@ export default class Version {
78
80
 
79
81
  log.debug(` ==> level: ${level}`);
80
82
  if (!["major", "minor", "patch"].includes(level)) {
81
- // @ts-expect-error
82
- throw new schemas.ValidationError('Parameter "version" is not valid');
83
+ throw new ValidationError('Parameter "version" is not valid');
83
84
  }
84
85
 
85
86
  log.debug(` ==> files: ${JSON.stringify(files)}`);
86
87
  if (!files) {
87
- // @ts-expect-error
88
- throw new schemas.ValidationError('Parameter "files" is not valid');
88
+ throw new ValidationError('Parameter "files" is not valid');
89
89
  }
90
90
 
91
91
  log.debug(` ==> map: ${JSON.stringify(map)}`);
92
92
  if (!Array.isArray(map)) {
93
- // @ts-expect-error
94
- throw new schemas.ValidationError('Parameter "map" is not valid');
93
+ throw new ValidationError('Parameter "map" is not valid');
95
94
  }
96
95
 
97
96
  log.debug("Checking local package version");
@@ -118,7 +117,7 @@ export default class Version {
118
117
 
119
118
  let localHash;
120
119
  try {
121
- makeDirectorySync(path);
120
+ mkdirSync(path, { recursive: true });
122
121
  const eikPathDest = join(path, configFile);
123
122
  const eikJSON = {
124
123
  name,
@@ -130,23 +129,22 @@ export default class Version {
130
129
  writeFileSync(eikPathDest, JSON.stringify(eikJSON, null, 2));
131
130
 
132
131
  const localFiles = [eikPathDest];
133
- log.debug(` ==> ${eikPathDest}`);
132
+ log.debug(` ==> ${eikPathDest} (hash: ${await hashFile(eikPathDest)})`);
134
133
 
135
134
  if (files) {
136
- try {
137
- const mappings = await this.config.mappings();
138
-
139
- for (const mapping of mappings) {
140
- const destination = join(path, mapping.destination.filePathname);
141
- copyFileSync(mapping.source.absolute, destination);
142
- log.debug(` ==> ${destination}`);
143
- localFiles.push(destination);
144
- }
145
- } catch (err) {
146
- // throw new Error(`Failed to zip JavaScripts: ${err.message}`);
135
+ const mappings = await this.config.mappings();
136
+
137
+ for (const mapping of mappings) {
138
+ const dest = join(path, mapping.destination.filePathname);
139
+ const destDir = dest.substring(0, dest.lastIndexOf("/"));
140
+ mkdirSync(normalize(destDir), { recursive: true });
141
+ copyFileSync(mapping.source.absolute, dest);
142
+ const hash = await hashFile(dest);
143
+ log.debug(` ==> ${dest} (hash: ${hash})`);
144
+ localFiles.push(dest);
147
145
  }
148
146
  }
149
- localHash = await hash.files(localFiles);
147
+ localHash = await hashFiles(localFiles);
150
148
  } catch (err) {
151
149
  throw new Error(
152
150
  `Unable to hash local files for comparison: ${err.message}`,
@@ -156,7 +154,7 @@ export default class Version {
156
154
  log.debug(`Comparing hashes:`);
157
155
  log.debug(` ==> local: ${localHash}`);
158
156
  log.debug(` ==> remote: ${integrityHash}`);
159
- const same = hash.compare(integrityHash, localHash);
157
+ const same = hashCompare(integrityHash, localHash);
160
158
 
161
159
  if (same) {
162
160
  throw new Error(
@@ -165,7 +163,7 @@ export default class Version {
165
163
  }
166
164
 
167
165
  log.debug(`Incrementing by "${level}" level`);
168
- const newVersion = semver.inc(version, level);
166
+ const newVersion = inc(version, level);
169
167
  log.debug(` ==> ${newVersion}`);
170
168
  return newVersion;
171
169
  }
package/commands/alias.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import Alias from "../classes/alias.js";
2
- import { Alias as AliasFormatter } from "../formatters/index.js";
2
+ import AliasFormatter from "../formatters/alias.js";
3
3
  import { commandHandler } from "../utils/command-handler.js";
4
4
 
5
5
  export const command = "alias [name] [version] [alias]";
@@ -1,6 +1,6 @@
1
1
  import { join } from "path";
2
2
  import Integrity from "../classes/integrity.js";
3
- import json from "../utils/json/index.js";
3
+ import write from "../utils/json/write.js";
4
4
  import { commandHandler } from "../utils/command-handler.js";
5
5
 
6
6
  export const command = "integrity [name] [version]";
@@ -39,7 +39,7 @@ export const handler = commandHandler(
39
39
 
40
40
  if (integrity) {
41
41
  const filename = join(out, "integrity.json");
42
- await json.write(integrity, { cwd, filename });
42
+ await write(integrity, { cwd, filename });
43
43
  spinner.succeed(
44
44
  `integrity information for package "${name}" (v${version}) saved to "${filename}"`,
45
45
  );
package/commands/login.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import os from "os";
2
2
  import readline from "readline";
3
3
  import Login from "../classes/login.js";
4
- import json from "../utils/json/index.js";
4
+ import read from "../utils/json/read.js";
5
+ import write from "../utils/json/write.js";
5
6
  import { commandHandler } from "../utils/command-handler.js";
6
7
 
7
8
  const homedir = os.homedir();
@@ -79,14 +80,14 @@ export const handler = commandHandler(
79
80
 
80
81
  if (token) {
81
82
  const meta = /** @type {{ tokens: any }} */ (
82
- await json.read({ cwd: homedir, filename: ".eikrc" })
83
+ await read({ cwd: homedir, filename: ".eikrc" })
83
84
  );
84
85
 
85
86
  const tokens = new Map(meta.tokens);
86
87
  tokens.set(s, token);
87
88
  meta.tokens = Array.from(tokens);
88
89
 
89
- await json.write(meta, { cwd: homedir, filename: ".eikrc" });
90
+ await write(meta, { cwd: homedir, filename: ".eikrc" });
90
91
  }
91
92
  },
92
93
  );
@@ -1,5 +1,5 @@
1
1
  import Alias from "../classes/alias.js";
2
- import { Alias as AliasFormatter } from "../formatters/index.js";
2
+ import AliasFormatter from "../formatters/alias.js";
3
3
  import { commandHandler } from "../utils/command-handler.js";
4
4
 
5
5
  export const command = "map-alias <name> <version> <alias>";
package/commands/map.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { join } from "path";
2
2
  import PublishMap from "../classes/publish/map.js";
3
- import { Artifact } from "../formatters/index.js";
3
+ import Artifact from "../formatters/artifact.js";
4
4
  import { commandHandler } from "../utils/command-handler.js";
5
5
 
6
6
  export const command = "map <name> <version> <file>";
package/commands/meta.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import Meta from "../classes/meta.js";
2
- import { Artifact } from "../formatters/index.js";
2
+ import Artifact from "../formatters/artifact.js";
3
3
  import { commandHandler } from "../utils/command-handler.js";
4
4
 
5
5
  export const command = "meta <name>";
@@ -1,5 +1,5 @@
1
1
  import Alias from "../classes/alias.js";
2
- import { Alias as AliasFormatter } from "../formatters/index.js";
2
+ import AliasFormatter from "../formatters/alias.js";
3
3
  import { commandHandler } from "../utils/command-handler.js";
4
4
 
5
5
  export const command = "npm-alias <name> <version> <alias>";
@@ -1,5 +1,5 @@
1
1
  import Alias from "../classes/alias.js";
2
- import { Alias as AliasFormatter } from "../formatters/index.js";
2
+ import AliasFormatter from "../formatters/alias.js";
3
3
  import { commandHandler } from "../utils/command-handler.js";
4
4
 
5
5
  export const command = "package-alias [name] [version] [alias]";
@@ -1,8 +1,9 @@
1
1
  import { join } from "path";
2
- import chalk from "chalk";
3
- import PublishPackage from "../classes/publish/package/index.js";
4
- import { typeSlug, typeTitle } from "../utils/index.js";
5
- import { Artifact } from "../formatters/index.js";
2
+ import c from "tinyrainbow";
3
+ import PublishPackage from "../classes/publish/package/publish.js";
4
+ import typeSlug from "@eik/common/lib/helpers/type-slug.js";
5
+ import typeTitle from "../utils/type-title.js";
6
+ import Artifact from "../formatters/artifact.js";
6
7
  import { EikCliError, errors } from "../utils/error.js";
7
8
  import { commandHandler } from "../utils/command-handler.js";
8
9
 
@@ -105,20 +106,18 @@ export const handler = commandHandler(
105
106
  spinner.stopAndPersist();
106
107
 
107
108
  process.stdout.write(
108
- `:: ${chalk.bgYellow.white.bold(
109
- typeTitle(type),
110
- )} > ${chalk.green(name)} | ${chalk.bold("dry run")}`,
109
+ `:: ${c.bgYellow(
110
+ c.white(c.bold(typeTitle(type))),
111
+ )} > ${c.green(name)} | ${c.bold("dry run")}`,
111
112
  );
112
113
  process.stdout.write("\n\n");
113
114
  process.stdout.write(" files (local temporary):\n");
114
115
  for (const file of fls) {
115
- process.stdout.write(` - ${chalk.bold("type")}: ${file.type}\n`);
116
- process.stdout.write(
117
- ` ${chalk.bold("path")}: ${file.pathname}\n\n`,
118
- );
116
+ process.stdout.write(` - ${c.bold("type")}: ${file.type}\n`);
117
+ process.stdout.write(` ${c.bold("path")}: ${file.pathname}\n\n`);
119
118
  }
120
119
  process.stdout.write(
121
- ` ${chalk.bold("No files were published to remote server")}\n\n`,
120
+ ` ${c.bold("No files were published to remote server")}\n\n`,
122
121
  );
123
122
  }
124
123
  },
@@ -1,7 +1,7 @@
1
1
  import { execSync } from "child_process";
2
2
  import { join } from "path";
3
3
  import VersionPackage from "../classes/version.js";
4
- import json from "../utils/json/index.js";
4
+ import writeEik from "../utils/json/write-eik.js";
5
5
  import { EikCliError, errors } from "../utils/error.js";
6
6
  import { commandHandler } from "../utils/command-handler.js";
7
7
 
@@ -68,11 +68,7 @@ export const handler = commandHandler(
68
68
  );
69
69
  } else {
70
70
  log.debug(`Writing new version ${newVersion} to ${configFile}`);
71
- // @ts-expect-error
72
- await json.writeEik(
73
- { version: newVersion },
74
- { cwd, filename: configFile },
75
- );
71
+ await writeEik({ version: newVersion }, { cwd, filename: configFile });
76
72
 
77
73
  log.debug(`Committing ${configFile} to local git repository`);
78
74
  try {
@@ -1,21 +1,21 @@
1
- import { join } from "path";
2
- import chalk from "chalk";
1
+ import { join } from "node:path";
2
+ import c from "tinyrainbow";
3
3
  import File from "./file.js";
4
4
 
5
5
  function colorType(type) {
6
6
  if (type === "npm") {
7
- return chalk.white.bgRed.bold(" NPM ");
7
+ return c.white(c.bgRed(c.bold(" NPM ")));
8
8
  }
9
9
 
10
10
  if (type === "pkg") {
11
- return chalk.white.bgYellow.bold(" PACKAGE ");
11
+ return c.white(c.bgYellow(c.bold(" PACKAGE ")));
12
12
  }
13
13
 
14
14
  if (type === "img") {
15
- return chalk.white.bgYellow.bold(" IMAGE ");
15
+ return c.white(c.bgYellow(c.bold(" IMAGE ")));
16
16
  }
17
17
 
18
- return chalk.white.bgBlue.bold(" IMPORT MAP ");
18
+ return c.white(c.bgBlue(c.bold(" IMPORT MAP ")));
19
19
  }
20
20
 
21
21
  class Alias {
@@ -45,27 +45,27 @@ class Alias {
45
45
 
46
46
  write(`:: `);
47
47
 
48
- write(`${colorType(this.type)} > ${chalk.green(this.name)} | `);
49
- write(`${chalk.bold("org:")} ${this.org} | `);
50
- write(`${chalk.bold("version:")} ${this.version} | `);
51
- write(`${chalk.bold("alias:")} v${this.alias} `);
48
+ write(`${colorType(this.type)} > ${c.green(this.name)} | `);
49
+ write(`${c.bold("org:")} ${this.org} | `);
50
+ write(`${c.bold("version:")} ${this.version} | `);
51
+ write(`${c.bold("alias:")} v${this.alias} `);
52
52
 
53
53
  if (this.update) {
54
- write(`${chalk.bgMagenta.white(" UPDATED \n\n")}`);
54
+ write(`${c.bgMagenta(c.white(" UPDATED \n\n"))}`);
55
55
  } else {
56
- write(`${chalk.bgGreen.white(" NEW ")}\n\n`);
56
+ write(`${c.bgGreen(c.white(" NEW "))}\n\n`);
57
57
  }
58
58
 
59
59
  if (url.href) {
60
- write(` ${chalk.bold("url: ")} ${chalk.cyan(url.href)}\n`);
60
+ write(` ${c.bold("url: ")} ${c.cyan(url.href)}\n`);
61
61
  }
62
62
 
63
63
  if (this.integrity) {
64
- write(` ${chalk.bold("integrity:")} ${this.integrity}\n`);
64
+ write(` ${c.bold("integrity:")} ${this.integrity}\n`);
65
65
  }
66
66
 
67
67
  if (this.files.length) {
68
- write(`\n ${chalk.bold("files:")}\n`);
68
+ write(`\n ${c.bold("files:")}\n`);
69
69
  }
70
70
 
71
71
  for (const file of this.files) {
@@ -1,5 +1,5 @@
1
1
  import { join } from "path";
2
- import chalk from "chalk";
2
+ import c from "tinyrainbow";
3
3
  import Version from "./version.js";
4
4
 
5
5
  const _name = Symbol("name");
@@ -9,18 +9,18 @@ const _versions = Symbol("versions");
9
9
 
10
10
  function colorType(type) {
11
11
  if (type === "npm") {
12
- return chalk.white.bgRed.bold(" NPM ");
12
+ return c.white(c.bgRed(c.bold(" NPM ")));
13
13
  }
14
14
 
15
15
  if (type === "pkg") {
16
- return chalk.white.bgYellow.bold(" PACKAGE ");
16
+ return c.white(c.bgYellow(c.bold(" PACKAGE ")));
17
17
  }
18
18
 
19
19
  if (type === "img") {
20
- return chalk.white.bgYellow.bold(" IMAGE ");
20
+ return c.white(c.bgYellow(c.bold(" IMAGE ")));
21
21
  }
22
22
 
23
- return chalk.white.bgBlue.bold(" IMPORT MAP ");
23
+ return c.white(c.bgBlue(c.bold(" IMPORT MAP ")));
24
24
  }
25
25
 
26
26
  class Artifact {
@@ -71,12 +71,12 @@ class Artifact {
71
71
  const write = process.stdout.write.bind(process.stdout);
72
72
  const url = new URL(join(this.type, this.name), baseURL);
73
73
 
74
- write(`:: ${colorType(this.type)} > ${chalk.green(this.name)} | `);
75
- write(`${chalk.bold("org:")} ${this.org} | `);
76
- write(`${chalk.bold("url:")} ${chalk.cyan(url.href)}\n`);
74
+ write(`:: ${colorType(this.type)} > ${c.green(this.name)} | `);
75
+ write(`${c.bold("org:")} ${this.org} | `);
76
+ write(`${c.bold("url:")} ${c.cyan(url.href)}\n`);
77
77
 
78
78
  if (this.versions.length) {
79
- write(`\n ${chalk.bold("versions:")}\n`);
79
+ write(`\n ${c.bold("versions:")}\n`);
80
80
  }
81
81
 
82
82
  for (const version of this.versions) {
@@ -1,5 +1,5 @@
1
1
  import { join } from "path";
2
- import chalk from "chalk";
2
+ import c from "tinyrainbow";
3
3
 
4
4
  function readableBytes(bytes) {
5
5
  const i = Math.floor(Math.log(bytes) / Math.log(1024)),
@@ -25,10 +25,10 @@ class File {
25
25
  const url = new URL(baseURL);
26
26
 
27
27
  const fileUrl = new URL(join(url.pathname, this.pathname), url.origin);
28
- write(` - ${chalk.cyan(fileUrl.href)} `);
29
- write(`${chalk.yellow(this.mimeType)} `);
30
- write(`${chalk.magenta(readableBytes(this.size))}\n`);
31
- write(` ${chalk.bold("integrity:")} ${this.integrity}\n`);
28
+ write(` - ${c.cyan(fileUrl.href)} `);
29
+ write(`${c.yellow(this.mimeType)} `);
30
+ write(`${c.magenta(readableBytes(this.size))}\n`);
31
+ write(` ${c.bold("integrity:")} ${this.integrity}\n`);
32
32
  }
33
33
  }
34
34
 
@@ -1,5 +1,5 @@
1
1
  import { join } from "path";
2
- import chalk from "chalk";
2
+ import c from "tinyrainbow";
3
3
  import { formatDistance } from "date-fns/formatDistance";
4
4
  import File from "./file.js";
5
5
 
@@ -31,12 +31,12 @@ class Version {
31
31
  const url = new URL(baseURL);
32
32
  const bURL = new URL(join(url.pathname, this.version), url.origin);
33
33
 
34
- write(` - ${chalk.green(this.version)}\n`);
35
- write(` ${chalk.bold("url:")} ${chalk.cyan(bURL.href)}\n`);
36
- write(` ${chalk.bold("integrity:")} ${this.integrity}\n`);
34
+ write(` - ${c.green(this.version)}\n`);
35
+ write(` ${c.bold("url:")} ${c.cyan(bURL.href)}\n`);
36
+ write(` ${c.bold("integrity:")} ${this.integrity}\n`);
37
37
 
38
38
  if (this.files && this.files.length) {
39
- write(`\n ${chalk.bold("files:")}\n`);
39
+ write(`\n ${c.bold("files:")}\n`);
40
40
  for (const file of this.files) {
41
41
  new File(file).format(bURL.href);
42
42
  write(`\n`);
@@ -47,11 +47,11 @@ class Version {
47
47
  const d = formatDistance(new Date(this.created * 1000), new Date(), {
48
48
  addSuffix: true,
49
49
  });
50
- write(` ${chalk.bold("published")} ${chalk.yellow(d)}`);
50
+ write(` ${c.bold("published")} ${c.yellow(d)}`);
51
51
  }
52
52
 
53
53
  if (this.author && this.author.name) {
54
- write(` ${chalk.bold("by")} ${chalk.yellow(this.author.name)}`);
54
+ write(` ${c.bold("by")} ${c.yellow(this.author.name)}`);
55
55
  }
56
56
  }
57
57
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eik/cli",
3
- "version": "3.1.17",
3
+ "version": "3.1.19",
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",
@@ -38,26 +38,24 @@
38
38
  "author": "",
39
39
  "license": "MIT",
40
40
  "dependencies": {
41
- "@eik/common": "4.1.1",
41
+ "@eik/common": "5.1.5",
42
42
  "abslog": "2.4.4",
43
43
  "bytes": "3.1.2",
44
- "chalk": "5.4.1",
45
44
  "date-fns": "3.6.0",
46
45
  "form-data": "4.0.3",
47
46
  "gzip-size": "7.0.0",
48
- "make-dir": "5.0.0",
49
47
  "ora": "8.2.0",
50
48
  "rimraf": "6.0.1",
51
49
  "semver": "7.7.2",
52
- "ssri": "10.0.6",
53
50
  "tar": "7.4.3",
51
+ "tinyrainbow": "2.0.0",
54
52
  "yargs": "17.7.2",
55
53
  "yargs-parser": "21.1.1"
56
54
  },
57
55
  "devDependencies": {
58
56
  "@eik/eslint-config": "1.0.16",
59
57
  "@eik/prettier-config": "1.0.1",
60
- "@eik/semantic-release-config": "1.0.4",
58
+ "@eik/semantic-release-config": "1.0.5",
61
59
  "@eik/service": "2.3.2",
62
60
  "@eik/sink-memory": "1.1.3",
63
61
  "@eik/typescript-config": "1.0.0",
@@ -28,7 +28,7 @@ export default class Alias {
28
28
  log: abslog.ValidLogger;
29
29
  server: string;
30
30
  token: string;
31
- type: string;
31
+ type: any;
32
32
  name: string;
33
33
  alias: string;
34
34
  version: string;
@@ -26,9 +26,9 @@ declare namespace _default {
26
26
  */
27
27
  function ping(opts: import("./ping.js").PingOptions): Promise<boolean>;
28
28
  /**
29
- * @param {import('./publish/package/index.js').PublishOptions} opts
29
+ * @param {import('./publish/package/publish.js').PublishOptions} opts
30
30
  */
31
- function publish(opts: import("./publish/package/index.js").PublishOptions): Promise<import("./publish/package/index.js").PublishResult>;
31
+ function publish(opts: import("./publish/package/publish.js").PublishOptions): Promise<import("./publish/package/publish.js").PublishResult>;
32
32
  /**
33
33
  * @param {import('./version.js').VersionOptions} opts
34
34
  */
@@ -18,9 +18,9 @@ export default class Version {
18
18
  */
19
19
  constructor({ logger, server, type, name, version, level, cwd, map, out, files, configFile, }: VersionOptions);
20
20
  log: abslog.ValidLogger;
21
- config: EikConfig;
21
+ config: any;
22
22
  configFile: string;
23
- path: string;
23
+ path: any;
24
24
  level: any;
25
25
  /**
26
26
  * Similar to `npm version`, but updates `eik.json`
@@ -42,4 +42,3 @@ export type VersionOptions = {
42
42
  configFile?: string;
43
43
  };
44
44
  import abslog from "abslog";
45
- import { EikConfig } from "@eik/common";
package/utils/defaults.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import fs from "fs";
2
2
  import { join, isAbsolute } from "path";
3
- import { helpers } from "@eik/common";
3
+ import configStore from "@eik/common/lib/helpers/config-store.js";
4
4
  import { EikCliError, errors } from "./error.js";
5
5
 
6
6
  const defaults = {
@@ -40,9 +40,9 @@ export function getArgsOrDefaults(argv, opts) {
40
40
  /** @type {import('@eik/common').EikConfig} */
41
41
  let eikConfig;
42
42
  if (stats.isDirectory()) {
43
- eikConfig = helpers.configStore.findInDirectory(path);
43
+ eikConfig = configStore.findInDirectory(path);
44
44
  } else {
45
- eikConfig = helpers.configStore.loadFromPath(path);
45
+ eikConfig = configStore.loadFromPath(path);
46
46
  config.configFile = configPath;
47
47
  }
48
48
  config = {
@@ -1,5 +1,5 @@
1
- import ssri from "ssri";
2
- import fs from "fs";
1
+ import { createHash } from "node:crypto";
2
+ import fs from "node:fs/promises";
3
3
 
4
4
  /**
5
5
  * Reads a file from a given path and produces and returns an integrity hash from its contents
@@ -11,6 +11,10 @@ import fs from "fs";
11
11
  * @example hash.file('/path/to/file.js');
12
12
  */
13
13
  export default async (path) => {
14
- const integrity = await ssri.fromStream(fs.createReadStream(path));
15
- return integrity.toString();
14
+ const alg = "sha512";
15
+ const digest = createHash(alg)
16
+ .update(await fs.readFile(path))
17
+ .digest()
18
+ .toString("base64");
19
+ return `${alg}-${digest}`;
16
20
  };
@@ -1,4 +1,4 @@
1
- import ssri from "ssri";
1
+ import { createHash } from "node:crypto";
2
2
  import fileHash from "./file.js";
3
3
 
4
4
  /**
@@ -12,10 +12,11 @@ import fileHash from "./file.js";
12
12
  */
13
13
  export default async (files) => {
14
14
  const hashes = await Promise.all(files.map(fileHash));
15
- const hasher = ssri.create();
15
+ const alg = "sha512";
16
+ const hasher = createHash(alg);
16
17
  for (const hash of hashes.sort()) {
17
18
  hasher.update(hash);
18
19
  }
19
- const integrity = hasher.digest();
20
- return integrity.toString();
20
+ const digest = hasher.digest().toString("base64");
21
+ return `${alg}-${digest}`;
21
22
  };
@@ -1,4 +1,4 @@
1
- import { join } from "path";
1
+ import { join } from "node:path";
2
2
 
3
3
  /**
4
4
  * Fetches package integrity string by name and version from a given Eik asset server.
@@ -1,6 +0,0 @@
1
- import Artifact from "./artifact.js";
2
- import Alias from "./alias.js";
3
- import File from "./file.js";
4
- import Version from "./version.js";
5
-
6
- export { Artifact, Alias, Version, File };
@@ -1,24 +0,0 @@
1
- /**
2
- * Get defaults for things like server, name and version from Eik config.
3
- * If a specific argument is given for it, that takes precedence.
4
- * @template [T=Record<string, unknown>]
5
- * @param {any} argv
6
- * @param {{ command: string; options?: string[] }} opts
7
- * @returns {import('@eik/common').EikConfig & typeof defaults & { configFile: string } & T}
8
- */
9
- export function getArgsOrDefaults<T = Record<string, unknown>>(argv: any, opts: {
10
- command: string;
11
- options?: string[];
12
- }): import("@eik/common").EikConfig & typeof defaults & {
13
- configFile: string;
14
- } & T;
15
- declare const defaults: {
16
- name: string;
17
- type: string;
18
- version: string;
19
- server: string;
20
- out: string;
21
- files: string;
22
- "import-map": any[];
23
- };
24
- export {};
@@ -1,19 +0,0 @@
1
- export namespace errors {
2
- let ERR_MISSING_CONFIG: string;
3
- let ERR_WRONG_TYPE: string;
4
- let ERR_VERSION_EXISTS: string;
5
- let ERR_NOT_GIT: string;
6
- let ERR_GIT_COMMIT: string;
7
- }
8
- export class EikCliError extends Error {
9
- /**
10
- * @param {string} errorCode
11
- * @param {string} message
12
- * @param {Error} [cause]
13
- */
14
- constructor(errorCode: string, message: string, cause?: Error);
15
- cause: Error;
16
- get errorCode(): string;
17
- get exitCode(): number;
18
- #private;
19
- }
@@ -1,9 +0,0 @@
1
- declare namespace _default {
2
- export { file };
3
- export { files };
4
- export { compare };
5
- }
6
- export default _default;
7
- import file from "./file.js";
8
- import files from "./files.js";
9
- import compare from "./compare.js";
@@ -1,12 +0,0 @@
1
- declare namespace _default {
2
- export { latestVersion };
3
- export { versions };
4
- export { integrity };
5
- export { request };
6
- }
7
- export default _default;
8
- import latestVersion from "./latest-version.js";
9
- import versions from "./versions.js";
10
- import integrity from "./integrity.js";
11
- import request from "./request.js";
12
- export { latestVersion, versions, integrity, request };
@@ -1,2 +0,0 @@
1
- declare function _default(server: string, type: any, name: string, major: string | number): Promise<string | null>;
2
- export default _default;
@@ -1,6 +0,0 @@
1
- import logger from "./logger.js";
2
- import { getArgsOrDefaults } from "./defaults.js";
3
- export const typeSlug: typeof helpers.typeSlug;
4
- import typeTitle from "./type-title.js";
5
- import { helpers } from "@eik/common";
6
- export { logger, getArgsOrDefaults, typeTitle };
@@ -1,9 +0,0 @@
1
- declare namespace _default {
2
- export { read };
3
- export { write };
4
- export { writeEik };
5
- }
6
- export default _default;
7
- import read from "./read.js";
8
- import write from "./write.js";
9
- import writeEik from "./write-eik.js";
@@ -1,5 +0,0 @@
1
- declare function _default(location: string | {
2
- filename: string;
3
- cwd: string;
4
- }): Promise<unknown>;
5
- export default _default;
@@ -1,5 +0,0 @@
1
- declare function _default(data: object, options: {
2
- cwd: string;
3
- filename: string;
4
- }): Promise<undefined>;
5
- export default _default;
@@ -1,33 +0,0 @@
1
- export default logger;
2
- /**
3
- * Creates a logger object that wraps an instance of the "ora" module in order to provide consistent command line logging that includes a spinner
4
- *
5
- * @param {object} spinner
6
- * @param {boolean} debug
7
- */
8
- declare function logger(spinner: object, debug?: boolean): {
9
- /**
10
- * @param {string} message
11
- */
12
- fatal(message: string): void;
13
- /**
14
- * @param {string} message
15
- */
16
- error(message: string): void;
17
- /**
18
- * @param {string} message
19
- */
20
- warn(message: string): void;
21
- /**
22
- * @param {string} message
23
- */
24
- info(message: string): void;
25
- /**
26
- * @param {string} message
27
- */
28
- debug(message: string): void;
29
- /**
30
- * @param {string} message
31
- */
32
- trace(message: string): void;
33
- };
@@ -1,2 +0,0 @@
1
- declare function _default(type: any): "PACKAGE" | "NPM" | "IMAGE" | "MAP";
2
- export default _default;
@@ -1,5 +0,0 @@
1
- import file from "./file.js";
2
- import files from "./files.js";
3
- import compare from "./compare.js";
4
-
5
- export default { file, files, compare };
@@ -1,7 +0,0 @@
1
- import latestVersion from "./latest-version.js";
2
- import versions from "./versions.js";
3
- import integrity from "./integrity.js";
4
- import request from "./request.js";
5
-
6
- export default { latestVersion, versions, integrity, request };
7
- export { latestVersion, versions, integrity, request };
package/utils/index.js DELETED
@@ -1,8 +0,0 @@
1
- import { helpers } from "@eik/common";
2
- import logger from "./logger.js";
3
- import typeTitle from "./type-title.js";
4
- import { getArgsOrDefaults } from "./defaults.js";
5
-
6
- const { typeSlug } = helpers;
7
-
8
- export { logger, getArgsOrDefaults, typeSlug, typeTitle };
@@ -1,5 +0,0 @@
1
- import read from "./read.js";
2
- import write from "./write.js";
3
- import writeEik from "./write-eik.js";
4
-
5
- export default { read, write, writeEik };