@eik/cli 3.1.1 → 3.1.3

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 CHANGED
@@ -1,3 +1,17 @@
1
+ ## [3.1.3](https://github.com/eik-lib/cli/compare/v3.1.2...v3.1.3) (2024-08-19)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * add support for Windows ([#584](https://github.com/eik-lib/cli/issues/584)) ([3d2dc7e](https://github.com/eik-lib/cli/commit/3d2dc7ef87abc48a3b4b796e5d717b280837974b))
7
+
8
+ ## [3.1.2](https://github.com/eik-lib/cli/compare/v3.1.1...v3.1.2) (2024-08-19)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **deps:** update eik packages ([d55f539](https://github.com/eik-lib/cli/commit/d55f53955cce60d0e07a9d79c3746fc14d0ea00d))
14
+
1
15
  ## [3.1.1](https://github.com/eik-lib/cli/compare/v3.1.0...v3.1.1) (2024-08-19)
2
16
 
3
17
 
package/classes/alias.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import assert from 'assert';
2
2
  import abslog from 'abslog';
3
- import { join } from 'path';
4
3
  import { schemas, validators } from '@eik/common';
5
4
  import { request } from '../utils/http/index.js';
6
5
  import { typeSlug } from '../utils/index.js';
6
+ import { joinUrlPathname } from '../utils/url.js';
7
7
 
8
8
  /**
9
9
  * @typedef {object} AliasOptions
@@ -74,7 +74,11 @@ export default class Alias {
74
74
  `Requesting creation of ${this.type} alias "v${this.alias}" for ${this.name} v${this.version} on ${this.server}`,
75
75
  );
76
76
 
77
- const pathname = join(this.type, this.name, `v${this.alias}`);
77
+ const pathname = joinUrlPathname(
78
+ this.type,
79
+ this.name,
80
+ `v${this.alias}`,
81
+ );
78
82
  try {
79
83
  const { message } = await request({
80
84
  host: this.server,
@@ -1,7 +1,7 @@
1
1
  import abslog from 'abslog';
2
- import { join } from 'path';
3
2
  import eik from '@eik/common';
4
3
  import { typeSlug } from '../utils/index.js';
4
+ import { joinUrlPathname } from '../utils/url.js';
5
5
 
6
6
  const { schemas } = eik;
7
7
 
@@ -79,7 +79,7 @@ export default class Integrity {
79
79
  this.log.debug('Requesting meta information from asset server');
80
80
  try {
81
81
  const url = new URL(
82
- join(typeSlug(this.type), this.name, this.version),
82
+ joinUrlPathname(typeSlug(this.type), this.name, this.version),
83
83
  this.server,
84
84
  );
85
85
  this.log.debug(` ==> url: ${url}`);
package/classes/meta.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import abslog from 'abslog';
2
- import { join } from 'path';
3
2
  import { schemas } from '@eik/common';
3
+ import { joinUrlPathname } from '../utils/url.js';
4
4
 
5
5
  const types = ['pkg', 'map', 'npm'];
6
6
 
@@ -40,7 +40,10 @@ export default class Meta {
40
40
  try {
41
41
  const typeFetches = [];
42
42
  for (const type of types) {
43
- const url = new URL(join(type, this.name), this.server);
43
+ const url = new URL(
44
+ joinUrlPathname(type, this.name),
45
+ this.server,
46
+ );
44
47
  url.search = `?t=${Date.now()}`;
45
48
  typeFetches.push(fetch(url));
46
49
  }
@@ -64,7 +67,7 @@ export default class Meta {
64
67
  for (let i = 0; i < data[type].versions.length; i++) {
65
68
  const { version } = data[type].versions[i];
66
69
  const url = new URL(
67
- join(type, name, version),
70
+ joinUrlPathname(type, name, version),
68
71
  this.server,
69
72
  );
70
73
 
@@ -4,6 +4,7 @@ import { join, parse, isAbsolute } from 'path';
4
4
  import { existsSync } from 'fs';
5
5
  import { schemas } from '@eik/common';
6
6
  import { request } from '../../utils/http/index.js';
7
+ import { joinUrlPathname } from '../../utils/url.js';
7
8
 
8
9
  /**
9
10
  * @typedef {object} PublishMapOptions
@@ -79,7 +80,7 @@ export default class PublishMap {
79
80
  await request({
80
81
  method: 'PUT',
81
82
  host: this.server,
82
- pathname: join('map', this.name, this.version),
83
+ pathname: joinUrlPathname('map', this.name, this.version),
83
84
  map: this.absoluteFile,
84
85
  token: this.token,
85
86
  });
@@ -46,7 +46,7 @@ export default class CheckIfAlreadyPublished extends Task {
46
46
 
47
47
  let localHash;
48
48
  try {
49
- const localFiles = [join(path, './eik.json')];
49
+ const localFiles = [join(path, 'eik.json')];
50
50
  if (files) {
51
51
  const mappings = await this.config.mappings();
52
52
 
@@ -1,6 +1,7 @@
1
- import { join } from 'path';
2
- import fs from 'fs';
3
- import { rimrafSync } from 'rimraf';
1
+ import { join } from 'node:path';
2
+ import { existsSync } from 'node:fs';
3
+ import { readdir } from 'node:fs/promises';
4
+ import { rimraf } from 'rimraf';
4
5
  import Task from './task.js';
5
6
 
6
7
  export default class Cleanup extends Task {
@@ -8,10 +9,13 @@ export default class Cleanup extends Task {
8
9
  const { log, path } = this;
9
10
  log.debug('Cleaning up');
10
11
 
11
- if (fs.existsSync(path)) {
12
- fs.readdirSync(path)
13
- .filter((file) => file !== 'integrity.json')
14
- .forEach((file) => rimrafSync(join(path, file)));
12
+ if (existsSync(path)) {
13
+ const dir = await readdir(path);
14
+ await Promise.all(
15
+ dir
16
+ .filter((file) => file !== 'integrity.json')
17
+ .map((file) => rimraf(join(path, file))),
18
+ );
15
19
  }
16
20
  }
17
21
  }
@@ -10,13 +10,13 @@ export default class CreateZipFile extends Task {
10
10
  const { log, path } = this;
11
11
  const { name, map, server, out, files } = this.config;
12
12
 
13
- log.debug(`Creating zip file`);
14
- log.debug(` ==> ${join(path, `eik.tgz`)}`);
13
+ log.debug('Creating zip file');
14
+ log.debug(` ==> ${join(path, 'eik.tgz')}`);
15
15
 
16
16
  const filesToZip = [];
17
17
 
18
18
  try {
19
- const eikPathDest = join(path, './eik.json');
19
+ const eikPathDest = join(path, 'eik.json');
20
20
  writeFileSync(
21
21
  eikPathDest,
22
22
  JSON.stringify(
@@ -59,7 +59,7 @@ export default class CreateZipFile extends Task {
59
59
  }
60
60
 
61
61
  try {
62
- const zipFile = resolve(`${path}/eik.tgz`);
62
+ const zipFile = resolve(path, 'eik.tgz');
63
63
 
64
64
  await tar.c(
65
65
  {
@@ -1,6 +1,7 @@
1
- import { join } from 'path';
2
1
  import { request } from '../../../../utils/http/index.js';
3
2
  import { typeSlug } from '../../../../utils/index.js';
3
+ import { joinUrlPathname } from '../../../../utils/url.js';
4
+
4
5
  import Task from './task.js';
5
6
 
6
7
  export default class UploadFiles extends Task {
@@ -9,7 +10,7 @@ export default class UploadFiles extends Task {
9
10
  const { server, name, version, type, token } = this.config;
10
11
  log.debug('Uploading zip file to server');
11
12
  try {
12
- const pathname = join(
13
+ const pathname = joinUrlPathname(
13
14
  typeSlug(type),
14
15
  encodeURIComponent(name),
15
16
  version,
@@ -124,7 +124,7 @@ export default class Version {
124
124
  let localHash;
125
125
  try {
126
126
  makeDirectorySync(path);
127
- const eikPathDest = join(path, './eik.json');
127
+ const eikPathDest = join(path, 'eik.json');
128
128
  const eikJSON = {
129
129
  name,
130
130
  server,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eik/cli",
3
- "version": "3.1.1",
3
+ "version": "3.1.3",
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 .",
@@ -42,7 +38,7 @@
42
38
  "author": "",
43
39
  "license": "MIT",
44
40
  "dependencies": {
45
- "@eik/common": "4.1.0",
41
+ "@eik/common": "4.1.1",
46
42
  "abslog": "2.4.4",
47
43
  "boxen": "8.0.1",
48
44
  "bytes": "3.1.2",
@@ -62,8 +58,8 @@
62
58
  "devDependencies": {
63
59
  "@eik/eslint-config": "1.0.2",
64
60
  "@eik/semantic-release-config": "1.0.0",
65
- "@eik/service": "2.3.0",
66
- "@eik/sink-memory": "1.1.1",
61
+ "@eik/service": "2.3.1",
62
+ "@eik/sink-memory": "1.1.2",
67
63
  "@eik/typescript-config": "1.0.0",
68
64
  "cross-env": "7.0.3",
69
65
  "eslint": "9.8.0",
@@ -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;
package/utils/url.js ADDED
@@ -0,0 +1,10 @@
1
+ import { join } from 'node:path';
2
+
3
+ /**
4
+ * A version of path.join that replaces \ (win32) with /
5
+ * @param {...string} parts
6
+ * @returns {string}
7
+ */
8
+ export function joinUrlPathname(...parts) {
9
+ return join(...parts).replace(/\\/g, '/');
10
+ }