@eik/cli 3.1.2 → 3.1.4

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 (79) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/classes/alias.js +108 -114
  3. package/classes/index.js +58 -58
  4. package/classes/integrity.js +89 -97
  5. package/classes/login.js +47 -47
  6. package/classes/meta.js +75 -77
  7. package/classes/ping.js +53 -53
  8. package/classes/publish/map.js +90 -91
  9. package/classes/publish/package/index.js +130 -130
  10. package/classes/publish/package/tasks/check-bundle-sizes.js +19 -21
  11. package/classes/publish/package/tasks/check-if-already-published.js +67 -72
  12. package/classes/publish/package/tasks/cleanup.js +17 -13
  13. package/classes/publish/package/tasks/create-temp-directory.js +17 -17
  14. package/classes/publish/package/tasks/create-zip-file.js +60 -65
  15. package/classes/publish/package/tasks/dry-run.js +15 -15
  16. package/classes/publish/package/tasks/save-metafile.js +17 -17
  17. package/classes/publish/package/tasks/task.js +7 -7
  18. package/classes/publish/package/tasks/upload-files.js +53 -56
  19. package/classes/publish/package/tasks/validate-input.js +24 -24
  20. package/classes/version.js +152 -163
  21. package/commands/alias.js +87 -87
  22. package/commands/index.js +24 -24
  23. package/commands/init.js +98 -105
  24. package/commands/integrity.js +52 -52
  25. package/commands/login.js +96 -98
  26. package/commands/map-alias.js +73 -73
  27. package/commands/map.js +72 -72
  28. package/commands/meta.js +49 -50
  29. package/commands/npm-alias.js +69 -69
  30. package/commands/package-alias.js +79 -80
  31. package/commands/ping.js +25 -25
  32. package/commands/publish.js +120 -124
  33. package/commands/version.js +86 -88
  34. package/formatters/alias.js +60 -63
  35. package/formatters/artifact.js +77 -77
  36. package/formatters/file.js +25 -25
  37. package/formatters/index.js +4 -4
  38. package/formatters/version.js +49 -51
  39. package/index.js +61 -61
  40. package/package.json +4 -7
  41. package/types/classes/alias.d.ts +1 -1
  42. package/types/classes/integrity.d.ts +1 -1
  43. package/types/classes/login.d.ts +1 -1
  44. package/types/classes/meta.d.ts +1 -1
  45. package/types/classes/ping.d.ts +1 -1
  46. package/types/classes/publish/map.d.ts +1 -1
  47. package/types/classes/publish/package/index.d.ts +11 -11
  48. package/types/classes/publish/package/tasks/check-bundle-sizes.d.ts +1 -1
  49. package/types/classes/publish/package/tasks/check-if-already-published.d.ts +1 -1
  50. package/types/classes/publish/package/tasks/cleanup.d.ts +1 -1
  51. package/types/classes/publish/package/tasks/create-temp-directory.d.ts +1 -1
  52. package/types/classes/publish/package/tasks/create-zip-file.d.ts +1 -1
  53. package/types/classes/publish/package/tasks/dry-run.d.ts +1 -1
  54. package/types/classes/publish/package/tasks/save-metafile.d.ts +1 -1
  55. package/types/classes/publish/package/tasks/task.d.ts +1 -1
  56. package/types/classes/publish/package/tasks/upload-files.d.ts +1 -1
  57. package/types/classes/publish/package/tasks/validate-input.d.ts +1 -1
  58. package/types/classes/version.d.ts +3 -3
  59. package/types/utils/hash/index.d.ts +3 -3
  60. package/types/utils/http/index.d.ts +4 -4
  61. package/types/utils/index.d.ts +3 -3
  62. package/types/utils/json/index.d.ts +3 -3
  63. package/types/utils/url.d.ts +6 -0
  64. package/utils/hash/file.js +4 -4
  65. package/utils/hash/files.js +9 -9
  66. package/utils/hash/index.js +3 -3
  67. package/utils/http/index.js +4 -4
  68. package/utils/http/integrity.js +18 -18
  69. package/utils/http/latest-version.js +37 -37
  70. package/utils/http/request.js +42 -42
  71. package/utils/http/versions.js +20 -20
  72. package/utils/index.js +3 -3
  73. package/utils/json/index.js +3 -3
  74. package/utils/json/read.js +26 -26
  75. package/utils/json/write-eik.js +17 -17
  76. package/utils/json/write.js +26 -28
  77. package/utils/logger.js +43 -43
  78. package/utils/type-title.js +3 -3
  79. package/utils/url.js +10 -0
@@ -1,61 +1,59 @@
1
- import { join } from 'path';
2
- import chalk from 'chalk';
3
- import { formatDistance } from 'date-fns/formatDistance';
4
- import File from './file.js';
1
+ import { join } from "path";
2
+ import chalk from "chalk";
3
+ import { formatDistance } from "date-fns/formatDistance";
4
+ import File from "./file.js";
5
5
 
6
6
  class Version {
7
- constructor({
8
- version = '',
9
- integrity = '',
10
- author = {},
11
- created = null,
12
- type = '',
13
- name = '',
14
- org = '',
15
- files = [],
16
- meta = [],
17
- } = {}) {
18
- this.version = version;
19
- this.integrity = integrity;
20
- this.author = author;
21
- this.created = created;
22
- this.type = type;
23
- this.name = name;
24
- this.org = org;
25
- this.files = files;
26
- this.meta = meta;
27
- }
7
+ constructor({
8
+ version = "",
9
+ integrity = "",
10
+ author = {},
11
+ created = null,
12
+ type = "",
13
+ name = "",
14
+ org = "",
15
+ files = [],
16
+ meta = [],
17
+ } = {}) {
18
+ this.version = version;
19
+ this.integrity = integrity;
20
+ this.author = author;
21
+ this.created = created;
22
+ this.type = type;
23
+ this.name = name;
24
+ this.org = org;
25
+ this.files = files;
26
+ this.meta = meta;
27
+ }
28
28
 
29
- format(baseURL = '') {
30
- const write = process.stdout.write.bind(process.stdout);
31
- const url = new URL(baseURL);
32
- const bURL = new URL(join(url.pathname, this.version), url.origin);
29
+ format(baseURL = "") {
30
+ const write = process.stdout.write.bind(process.stdout);
31
+ const url = new URL(baseURL);
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(` - ${chalk.green(this.version)}\n`);
35
+ write(` ${chalk.bold("url:")} ${chalk.cyan(bURL.href)}\n`);
36
+ write(` ${chalk.bold("integrity:")} ${this.integrity}\n`);
37
37
 
38
- if (this.files && this.files.length) {
39
- write(`\n ${chalk.bold('files:')}\n`);
40
- for (const file of this.files) {
41
- new File(file).format(bURL.href);
42
- write(`\n`);
43
- }
44
- }
38
+ if (this.files && this.files.length) {
39
+ write(`\n ${chalk.bold("files:")}\n`);
40
+ for (const file of this.files) {
41
+ new File(file).format(bURL.href);
42
+ write(`\n`);
43
+ }
44
+ }
45
45
 
46
- if (this.created) {
47
- const d = formatDistance(
48
- new Date(this.created * 1000),
49
- new Date(),
50
- { addSuffix: true },
51
- );
52
- write(` ${chalk.bold('published')} ${chalk.yellow(d)}`);
53
- }
46
+ if (this.created) {
47
+ const d = formatDistance(new Date(this.created * 1000), new Date(), {
48
+ addSuffix: true,
49
+ });
50
+ write(` ${chalk.bold("published")} ${chalk.yellow(d)}`);
51
+ }
54
52
 
55
- if (this.author && this.author.name) {
56
- write(` ${chalk.bold('by')} ${chalk.yellow(this.author.name)}`);
57
- }
58
- }
53
+ if (this.author && this.author.name) {
54
+ write(` ${chalk.bold("by")} ${chalk.yellow(this.author.name)}`);
55
+ }
56
+ }
59
57
  }
60
58
 
61
59
  export default Version;
package/index.js CHANGED
@@ -1,39 +1,39 @@
1
1
  #!/usr/bin/env node
2
- import chalk from 'chalk';
3
- import yargs from 'yargs';
4
- import { hideBin } from 'yargs/helpers';
5
- import boxen from 'boxen';
6
- import { join } from 'path';
7
- import { readFileSync } from 'fs';
8
- import { fileURLToPath } from 'url';
9
- import { dirname } from 'path';
10
- import { commands } from './commands/index.js';
2
+ import chalk from "chalk";
3
+ import yargs from "yargs";
4
+ import { hideBin } from "yargs/helpers";
5
+ import boxen from "boxen";
6
+ import { join } from "path";
7
+ import { readFileSync } from "fs";
8
+ import { fileURLToPath } from "url";
9
+ import { dirname } from "path";
10
+ import { commands } from "./commands/index.js";
11
11
 
12
12
  const __filename = fileURLToPath(import.meta.url);
13
13
  const __dirname = dirname(__filename);
14
14
 
15
15
  const { version } = JSON.parse(
16
- readFileSync(join(__dirname, './package.json'), { encoding: 'utf-8' }),
16
+ readFileSync(join(__dirname, "./package.json"), { encoding: "utf-8" }),
17
17
  );
18
18
 
19
19
  // short circuit and provide a -v and --version flag
20
20
  if (
21
- process.argv.includes('-v') ||
22
- // last position only to avoid conflict with publish command
23
- process.argv[process.argv.length - 1].includes('--version')
21
+ process.argv.includes("-v") ||
22
+ // last position only to avoid conflict with publish command
23
+ process.argv[process.argv.length - 1].includes("--version")
24
24
  ) {
25
- console.log(version);
26
- process.exit(0);
25
+ console.log(version);
26
+ process.exit(0);
27
27
  }
28
28
 
29
29
  const greeting = chalk.white.bold(`Eik CLI (v${version})`);
30
30
 
31
31
  const boxenOptions = {
32
- padding: 1,
33
- margin: 1,
34
- borderStyle: 'round',
35
- borderColor: 'green',
36
- backgroundColor: '#555555',
32
+ padding: 1,
33
+ margin: 1,
34
+ borderStyle: "round",
35
+ borderColor: "green",
36
+ backgroundColor: "#555555",
37
37
  };
38
38
  // @ts-expect-error
39
39
  const msgBox = boxen(greeting, boxenOptions);
@@ -41,44 +41,44 @@ const msgBox = boxen(greeting, boxenOptions);
41
41
  console.log(msgBox);
42
42
 
43
43
  yargs(hideBin(process.argv))
44
- .options({
45
- config: {
46
- alias: 'c',
47
- describe:
48
- 'Provide an exact path to an eik.json or package.json file to use as config. Default is eik.json in the current working directory.',
49
- },
50
- cwd: {
51
- describe: 'Alter the current working directory.',
52
- default: process.cwd(),
53
- },
54
- debug: {
55
- describe: 'Logs additional messages',
56
- default: false,
57
- type: 'boolean',
58
- },
59
- })
60
- // @ts-expect-error
61
- .example('eik init')
62
- // @ts-expect-error
63
- .example('eik login --server https://assets.myserver.com --key ######')
64
- // @ts-expect-error
65
- .example('eik publish')
66
- // @ts-expect-error
67
- .example('eik meta my-app --server https://assets.myserver.com')
68
- .example(
69
- // @ts-expect-error
70
- 'eik npm-alias lit-html 1.0.0 1 --server https://assets.myserver.com --token ######',
71
- )
72
- .example(
73
- // @ts-expect-error
74
- 'eik map my-map 1.0.0 ./import-map.json --server https://assets.myserver.com --token ######',
75
- )
76
- // @ts-expect-error
77
- .example('eik map-alias my-map 1.0.0 1')
78
- // @ts-expect-error
79
- .command(commands)
80
- .demandCommand()
81
- .wrap(150)
82
- .version(false)
83
- .help()
84
- .parse();
44
+ .options({
45
+ config: {
46
+ alias: "c",
47
+ describe:
48
+ "Provide an exact path to an eik.json or package.json file to use as config. Default is eik.json in the current working directory.",
49
+ },
50
+ cwd: {
51
+ describe: "Alter the current working directory.",
52
+ default: process.cwd(),
53
+ },
54
+ debug: {
55
+ describe: "Logs additional messages",
56
+ default: false,
57
+ type: "boolean",
58
+ },
59
+ })
60
+ // @ts-expect-error
61
+ .example("eik init")
62
+ // @ts-expect-error
63
+ .example("eik login --server https://assets.myserver.com --key ######")
64
+ // @ts-expect-error
65
+ .example("eik publish")
66
+ // @ts-expect-error
67
+ .example("eik meta my-app --server https://assets.myserver.com")
68
+ .example(
69
+ // @ts-expect-error
70
+ "eik npm-alias lit-html 1.0.0 1 --server https://assets.myserver.com --token ######",
71
+ )
72
+ .example(
73
+ // @ts-expect-error
74
+ "eik map my-map 1.0.0 ./import-map.json --server https://assets.myserver.com --token ######",
75
+ )
76
+ // @ts-expect-error
77
+ .example("eik map-alias my-map 1.0.0 1")
78
+ // @ts-expect-error
79
+ .command(commands)
80
+ .demandCommand()
81
+ .wrap(150)
82
+ .version(false)
83
+ .help()
84
+ .parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eik/cli",
3
- "version": "3.1.2",
3
+ "version": "3.1.4",
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",
@@ -25,10 +25,6 @@
25
25
  "test:integration": "cross-env HTTP_PORT=0 LOG_LEVEL=fatal tap --timeout 0 --disable-coverage test/integration/**/*.test.mjs",
26
26
  "test:unit": "cross-env HTTP_PORT=0 LOG_LEVEL=fatal tap --timeout 0 --disable-coverage test/*.test.mjs",
27
27
  "test:tasks": "cross-env HTTP_PORT=0 LOG_LEVEL=fatal tap --timeout 0 --disable-coverage test/tasks/*.test.mjs",
28
- "test:ci:integration": "npm run test:integration -- --jobs=1",
29
- "test:ci:unit": "npm run test:unit -- --jobs=1",
30
- "test:ci:tasks": "npm run test:tasks -- --jobs=1",
31
- "test:ci": "run-s test:ci:*",
32
28
  "lint": "eslint .",
33
29
  "lint:fix": "eslint --fix .",
34
30
  "format:check": "prettier -c .",
@@ -51,7 +47,7 @@
51
47
  "form-data": "4.0.0",
52
48
  "gzip-size": "7.0.0",
53
49
  "make-dir": "5.0.0",
54
- "ora": "8.0.1",
50
+ "ora": "8.1.0",
55
51
  "rimraf": "6.0.1",
56
52
  "semver": "7.6.3",
57
53
  "ssri": "10.0.6",
@@ -61,8 +57,9 @@
61
57
  },
62
58
  "devDependencies": {
63
59
  "@eik/eslint-config": "1.0.2",
60
+ "@eik/prettier-config": "1.0.1",
64
61
  "@eik/semantic-release-config": "1.0.0",
65
- "@eik/service": "2.3.0",
62
+ "@eik/service": "2.3.1",
66
63
  "@eik/sink-memory": "1.1.2",
67
64
  "@eik/typescript-config": "1.0.0",
68
65
  "cross-env": "7.0.3",
@@ -57,4 +57,4 @@ export type AliasResult = {
57
57
  org: string;
58
58
  integrity: string;
59
59
  };
60
- import abslog from 'abslog';
60
+ import abslog from "abslog";
@@ -32,4 +32,4 @@ export type IntegrityOptions = {
32
32
  cwd?: string;
33
33
  debug?: boolean;
34
34
  };
35
- import abslog from 'abslog';
35
+ import abslog from "abslog";
@@ -22,4 +22,4 @@ export type LoginOptions = {
22
22
  server: string;
23
23
  key: string;
24
24
  };
25
- import abslog from 'abslog';
25
+ import abslog from "abslog";
@@ -25,4 +25,4 @@ export type MetaOptions = {
25
25
  name: string;
26
26
  version: string;
27
27
  };
28
- import abslog from 'abslog';
28
+ import abslog from "abslog";
@@ -20,4 +20,4 @@ export type PingOptions = {
20
20
  server?: string;
21
21
  logger?: import("abslog").AbstractLoggerOptions;
22
22
  };
23
- import abslog from 'abslog';
23
+ import abslog from "abslog";
@@ -48,4 +48,4 @@ export type PublishMapResult = {
48
48
  version: string;
49
49
  type: string;
50
50
  };
51
- import abslog from 'abslog';
51
+ import abslog from "abslog";
@@ -81,14 +81,14 @@ export type PublishResult = {
81
81
  type: string;
82
82
  }>;
83
83
  };
84
- import abslog from 'abslog';
85
- import { EikConfig } from '@eik/common';
86
- import ValidateInput from './tasks/validate-input.js';
87
- import CreateTempDirectory from './tasks/create-temp-directory.js';
88
- import CreateZipFile from './tasks/create-zip-file.js';
89
- import CheckBundleSizes from './tasks/check-bundle-sizes.js';
90
- import DryRun from './tasks/dry-run.js';
91
- import CheckIfAlreadyPublished from './tasks/check-if-already-published.js';
92
- import UploadFiles from './tasks/upload-files.js';
93
- import SaveMetafile from './tasks/save-metafile.js';
94
- import Cleanup from './tasks/cleanup.js';
84
+ import abslog from "abslog";
85
+ import { EikConfig } from "@eik/common";
86
+ import ValidateInput from "./tasks/validate-input.js";
87
+ import CreateTempDirectory from "./tasks/create-temp-directory.js";
88
+ import CreateZipFile from "./tasks/create-zip-file.js";
89
+ import CheckBundleSizes from "./tasks/check-bundle-sizes.js";
90
+ import DryRun from "./tasks/dry-run.js";
91
+ import CheckIfAlreadyPublished from "./tasks/check-if-already-published.js";
92
+ import UploadFiles from "./tasks/upload-files.js";
93
+ import SaveMetafile from "./tasks/save-metafile.js";
94
+ import Cleanup from "./tasks/cleanup.js";
@@ -1,4 +1,4 @@
1
1
  export default class CheckBundleSizes extends Task {
2
2
  process(): Promise<void>;
3
3
  }
4
- import Task from './task.js';
4
+ import Task from "./task.js";
@@ -1,4 +1,4 @@
1
1
  export default class CheckIfAlreadyPublished extends Task {
2
2
  process(): Promise<string>;
3
3
  }
4
- import Task from './task.js';
4
+ import Task from "./task.js";
@@ -1,4 +1,4 @@
1
1
  export default class Cleanup extends Task {
2
2
  process(): Promise<void>;
3
3
  }
4
- import Task from './task.js';
4
+ import Task from "./task.js";
@@ -1,4 +1,4 @@
1
1
  export default class CreateTempDir extends Task {
2
2
  process(): Promise<void>;
3
3
  }
4
- import Task from './task.js';
4
+ import Task from "./task.js";
@@ -1,4 +1,4 @@
1
1
  export default class CreateZipFile extends Task {
2
2
  process(): Promise<string>;
3
3
  }
4
- import Task from './task.js';
4
+ import Task from "./task.js";
@@ -4,4 +4,4 @@ export default class DryRun extends Task {
4
4
  type: string;
5
5
  }[]>;
6
6
  }
7
- import Task from './task.js';
7
+ import Task from "./task.js";
@@ -1,4 +1,4 @@
1
1
  export default class SaveMetaFile extends Task {
2
2
  process(response: any): Promise<void>;
3
3
  }
4
- import Task from './task.js';
4
+ import Task from "./task.js";
@@ -5,4 +5,4 @@ export default class Task {
5
5
  path: any;
6
6
  config: any;
7
7
  }
8
- import abslog from 'abslog';
8
+ import abslog from "abslog";
@@ -1,4 +1,4 @@
1
1
  export default class UploadFiles extends Task {
2
2
  process(zipFile: any): Promise<any>;
3
3
  }
4
- import Task from './task.js';
4
+ import Task from "./task.js";
@@ -1,4 +1,4 @@
1
1
  export default class ValidateInput extends Task {
2
2
  process(): void;
3
3
  }
4
- import Task from './task.js';
4
+ import Task from "./task.js";
@@ -38,6 +38,6 @@ export type VersionOptions = {
38
38
  out?: string;
39
39
  files: string | Record<string, string>;
40
40
  };
41
- import abslog from 'abslog';
42
- import { EikConfig } from '@eik/common';
43
- import semver from 'semver';
41
+ import abslog from "abslog";
42
+ import { EikConfig } from "@eik/common";
43
+ import semver from "semver";
@@ -4,6 +4,6 @@ declare namespace _default {
4
4
  export { compare };
5
5
  }
6
6
  export default _default;
7
- import file from './file.js';
8
- import files from './files.js';
9
- import compare from './compare.js';
7
+ import file from "./file.js";
8
+ import files from "./files.js";
9
+ import compare from "./compare.js";
@@ -5,8 +5,8 @@ declare namespace _default {
5
5
  export { request };
6
6
  }
7
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';
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
12
  export { latestVersion, versions, integrity, request };
@@ -1,6 +1,6 @@
1
- import logger from './logger.js';
1
+ import logger from "./logger.js";
2
2
  export const getDefaults: typeof helpers.getDefaults;
3
3
  export const typeSlug: typeof helpers.typeSlug;
4
- import typeTitle from './type-title.js';
5
- import { helpers } from '@eik/common';
4
+ import typeTitle from "./type-title.js";
5
+ import { helpers } from "@eik/common";
6
6
  export { logger, typeTitle };
@@ -4,6 +4,6 @@ declare namespace _default {
4
4
  export { writeEik };
5
5
  }
6
6
  export default _default;
7
- import read from './read.js';
8
- import write from './write.js';
9
- import writeEik from './write-eik.js';
7
+ import read from "./read.js";
8
+ import write from "./write.js";
9
+ import writeEik from "./write-eik.js";
@@ -0,0 +1,6 @@
1
+ /**
2
+ * A version of path.join that replaces \ (win32) with /
3
+ * @param {...string} parts
4
+ * @returns {string}
5
+ */
6
+ export function joinUrlPathname(...parts: string[]): string;
@@ -1,5 +1,5 @@
1
- import ssri from 'ssri';
2
- import fs from 'fs';
1
+ import ssri from "ssri";
2
+ import fs from "fs";
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,6 @@ 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 integrity = await ssri.fromStream(fs.createReadStream(path));
15
+ return integrity.toString();
16
16
  };
@@ -1,5 +1,5 @@
1
- import ssri from 'ssri';
2
- import fileHash from './file.js';
1
+ import ssri from "ssri";
2
+ import fileHash from "./file.js";
3
3
 
4
4
  /**
5
5
  * Reads files from given paths and produces and returns an integrity hash from all files contents
@@ -11,11 +11,11 @@ import fileHash from './file.js';
11
11
  * @example hash.files(['/path/to/file1.js', '/path/to/file2.js']);
12
12
  */
13
13
  export default async (files) => {
14
- const hashes = await Promise.all(files.map(fileHash));
15
- const hasher = ssri.create();
16
- for (const hash of hashes.sort()) {
17
- hasher.update(hash);
18
- }
19
- const integrity = hasher.digest();
20
- return integrity.toString();
14
+ const hashes = await Promise.all(files.map(fileHash));
15
+ const hasher = ssri.create();
16
+ for (const hash of hashes.sort()) {
17
+ hasher.update(hash);
18
+ }
19
+ const integrity = hasher.digest();
20
+ return integrity.toString();
21
21
  };
@@ -1,5 +1,5 @@
1
- import file from './file.js';
2
- import files from './files.js';
3
- import compare from './compare.js';
1
+ import file from "./file.js";
2
+ import files from "./files.js";
3
+ import compare from "./compare.js";
4
4
 
5
5
  export default { file, files, compare };
@@ -1,7 +1,7 @@
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';
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
5
 
6
6
  export default { latestVersion, versions, integrity, request };
7
7
  export { latestVersion, versions, integrity, request };
@@ -1,4 +1,4 @@
1
- import { join } from 'path';
1
+ import { join } from "path";
2
2
 
3
3
  /**
4
4
  * Fetches package integrity string by name and version from a given Eik asset server.
@@ -12,24 +12,24 @@ import { join } from 'path';
12
12
  * @throws Error
13
13
  */
14
14
  export default async (server, type, name, version) => {
15
- const url = new URL(join(type, name, version), server);
16
- url.search = `?t=${Date.now()}`;
15
+ const url = new URL(join(type, name, version), server);
16
+ url.search = `?t=${Date.now()}`;
17
17
 
18
- const res = await fetch(url);
18
+ const res = await fetch(url);
19
19
 
20
- if (!res.ok) {
21
- if (res.status === 404) {
22
- return null;
23
- }
24
- throw new Error('Server responded with non 200 status code.');
25
- }
20
+ if (!res.ok) {
21
+ if (res.status === 404) {
22
+ return null;
23
+ }
24
+ throw new Error("Server responded with non 200 status code.");
25
+ }
26
26
 
27
- try {
28
- const body = await res.json();
29
- return body.integrity;
30
- } catch (err) {
31
- throw new Error(
32
- 'An error occurred while attempting to parse json response from server.',
33
- );
34
- }
27
+ try {
28
+ const body = await res.json();
29
+ return body.integrity;
30
+ } catch (err) {
31
+ throw new Error(
32
+ "An error occurred while attempting to parse json response from server.",
33
+ );
34
+ }
35
35
  };