@youcan/cli-kit 2.8.1 → 2.8.2

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.
@@ -1,28 +1,39 @@
1
- import crypto from 'node:crypto';
2
-
1
+ import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
+ import crypto from "node:crypto";
3
+ //#region lib/node/crypto.ts
4
+ var crypto_exports = /* @__PURE__ */ __exportAll({
5
+ base64URLEncode: () => base64URLEncode,
6
+ fileHash: () => fileHash,
7
+ hashString: () => hashString,
8
+ randomBytes: () => randomBytes,
9
+ randomHex: () => randomHex,
10
+ randomUUID: () => randomUUID,
11
+ sha1: () => sha1,
12
+ sha256: () => sha256
13
+ });
3
14
  function randomHex(size) {
4
- return crypto.randomBytes(size).toString('hex');
15
+ return crypto.randomBytes(size).toString("hex");
5
16
  }
6
17
  function base64URLEncode(str) {
7
- return str.toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/[=]/g, '');
18
+ return str.toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/[=]/g, "");
8
19
  }
9
20
  function sha256(str) {
10
- return crypto.createHash('sha256').update(str).digest();
21
+ return crypto.createHash("sha256").update(str).digest();
11
22
  }
12
23
  function sha1(str) {
13
- return crypto.createHash('sha1').update(str).digest('hex');
24
+ return crypto.createHash("sha1").update(str).digest("hex");
14
25
  }
15
26
  function hashString(str) {
16
- return crypto.createHash('sha1').update(str).digest('hex');
27
+ return crypto.createHash("sha1").update(str).digest("hex");
17
28
  }
18
29
  function fileHash(buff) {
19
- return crypto.createHash('md5').update(buff).digest('hex');
30
+ return crypto.createHash("md5").update(buff).digest("hex");
20
31
  }
21
32
  function randomBytes(size) {
22
- return crypto.randomBytes(size);
33
+ return crypto.randomBytes(size);
23
34
  }
24
35
  function randomUUID() {
25
- return crypto.randomUUID();
36
+ return crypto.randomUUID();
26
37
  }
27
-
28
- export { base64URLEncode, fileHash, hashString, randomBytes, randomHex, randomUUID, sha1, sha256 };
38
+ //#endregion
39
+ export { base64URLEncode, crypto_exports, fileHash, hashString, randomBytes, randomHex, randomUUID, sha1, sha256 };
package/dist/node/env.js CHANGED
@@ -1,41 +1,36 @@
1
- import process from 'node:process';
2
- import { ENV_VARS } from '../internal/node/constants.js';
3
-
1
+ import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
+ import { ENV_VARS } from "../internal/node/constants.js";
3
+ import process from "node:process";
4
+ //#region lib/node/env.ts
5
+ var env_exports = /* @__PURE__ */ __exportAll({
6
+ apiHostname: () => apiHostname,
7
+ get: () => get,
8
+ oauthClientId: () => oauthClientId,
9
+ sellerAreaHostname: () => sellerAreaHostname
10
+ });
4
11
  function get(key) {
5
- return process.env[ENV_VARS[key]];
12
+ return process.env[ENV_VARS[key]];
6
13
  }
7
14
  function oauthClientId() {
8
- switch (get('HOST_ENV')) {
9
- case 'dev':
10
- return '1';
11
- case 'test':
12
- return '11';
13
- case 'prod':
14
- default:
15
- return '398';
16
- }
15
+ switch (get("HOST_ENV")) {
16
+ case "dev": return "1";
17
+ case "test": return "11";
18
+ default: return "398";
19
+ }
17
20
  }
18
21
  function sellerAreaHostname() {
19
- switch (get('HOST_ENV')) {
20
- case 'dev':
21
- return 'seller-area.dotshop.com';
22
- case 'test':
23
- return 'seller-area.testyoucan.shop';
24
- case 'prod':
25
- default:
26
- return 'seller-area.youcan.shop';
27
- }
22
+ switch (get("HOST_ENV")) {
23
+ case "dev": return "seller-area.dotshop.com";
24
+ case "test": return "seller-area.testyoucan.shop";
25
+ default: return "seller-area.youcan.shop";
26
+ }
28
27
  }
29
28
  function apiHostname() {
30
- switch (get('HOST_ENV')) {
31
- case 'dev':
32
- return 'api.dotshop.com';
33
- case 'test':
34
- return 'api.testyoucan.shop';
35
- case 'prod':
36
- default:
37
- return 'api.youcan.shop';
38
- }
29
+ switch (get("HOST_ENV")) {
30
+ case "dev": return "api.dotshop.com";
31
+ case "test": return "api.testyoucan.shop";
32
+ default: return "api.youcan.shop";
33
+ }
39
34
  }
40
-
41
- export { apiHostname, get, oauthClientId, sellerAreaHostname };
35
+ //#endregion
36
+ export { apiHostname, env_exports, get, oauthClientId, sellerAreaHostname };
@@ -1,138 +1,144 @@
1
- import { createWriteStream, createReadStream } from 'node:fs';
2
- import FilesystemPromises from 'node:fs/promises';
3
- import { pipeline } from 'node:stream/promises';
4
- import { createGunzip } from 'node:zlib';
5
- import archiver from 'archiver';
6
- import chokidar from 'chokidar';
7
- import FsExtra from 'fs-extra';
8
- import { glob as glob$1 } from 'glob';
9
- import * as tar from 'tar';
10
- import { temporaryDirectoryTask } from 'tempy';
11
- import 'change-case';
12
- import './cli.js';
13
- import 'conf';
14
- import 'env-paths';
15
- import 'formdata-node';
16
- import 'formdata-node/file-from-path';
17
- import 'simple-git';
18
- import 'execa';
19
- import 'find-process';
20
- import 'get-port';
21
- import 'tcp-port-used';
22
- import 'node-fetch';
23
- import 'ramda';
24
- import { resolve } from './path.js';
25
- import 'kleur';
26
- import 'dayjs';
27
- import '../ui/components/DevOutput.js';
28
- import 'react';
29
- import 'ink';
30
-
1
+ import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
+ import { resolve } from "./path.js";
3
+ import "../index.js";
4
+ import { createReadStream, createWriteStream } from "node:fs";
5
+ import FilesystemPromises from "node:fs/promises";
6
+ import { pipeline } from "node:stream/promises";
7
+ import { createGunzip } from "node:zlib";
8
+ import archiver from "archiver";
9
+ import chokidar from "chokidar";
10
+ import FsExtra from "fs-extra";
11
+ import { glob as glob$1 } from "glob";
12
+ import * as tar from "tar";
13
+ import { temporaryDirectoryTask } from "tempy";
14
+ //#region lib/node/filesystem.ts
15
+ var filesystem_exports = /* @__PURE__ */ __exportAll({
16
+ archived: () => archived,
17
+ chmod: () => chmod,
18
+ decompressGzip: () => decompressGzip,
19
+ exists: () => exists,
20
+ extractTar: () => extractTar,
21
+ glob: () => glob,
22
+ isDirectory: () => isDirectory,
23
+ isExecutable: () => isExecutable,
24
+ mkdir: () => mkdir,
25
+ move: () => move,
26
+ readFile: () => readFile,
27
+ readJsonFile: () => readJsonFile,
28
+ readdir: () => readdir,
29
+ rm: () => rm,
30
+ stat: () => stat,
31
+ tapIntoTmp: () => tapIntoTmp,
32
+ unlink: () => unlink,
33
+ watch: () => watch,
34
+ writeFile: () => writeFile,
35
+ writeJsonFile: () => writeJsonFile
36
+ });
31
37
  async function exists(path) {
32
- try {
33
- await FilesystemPromises.access(path);
34
- return true;
35
- }
36
- catch {
37
- return false;
38
- }
38
+ try {
39
+ await FilesystemPromises.access(path);
40
+ return true;
41
+ } catch {
42
+ return false;
43
+ }
39
44
  }
40
45
  async function isExecutable(path) {
41
- if (!await exists(path)) {
42
- return false;
43
- }
44
- try {
45
- await FilesystemPromises.access(path, FilesystemPromises.constants.X_OK);
46
- return true;
47
- }
48
- catch {
49
- return false;
50
- }
46
+ if (!await exists(path)) return false;
47
+ try {
48
+ await FilesystemPromises.access(path, FilesystemPromises.constants.X_OK);
49
+ return true;
50
+ } catch {
51
+ return false;
52
+ }
51
53
  }
52
54
  async function isDirectory(path) {
53
- try {
54
- const stats = await FilesystemPromises.stat(path);
55
- return stats.isDirectory();
56
- }
57
- catch {
58
- return false;
59
- }
55
+ try {
56
+ return (await FilesystemPromises.stat(path)).isDirectory();
57
+ } catch {
58
+ return false;
59
+ }
60
60
  }
61
61
  async function tapIntoTmp(callback) {
62
- return temporaryDirectoryTask(callback);
62
+ return temporaryDirectoryTask(callback);
63
63
  }
64
64
  async function mkdir(path) {
65
- await FilesystemPromises.mkdir(path, { recursive: true });
65
+ await FilesystemPromises.mkdir(path, { recursive: true });
66
66
  }
67
67
  async function rm(path) {
68
- await FilesystemPromises.rm(path, { recursive: true });
68
+ await FilesystemPromises.rm(path, { recursive: true });
69
69
  }
70
70
  async function move(src, dest, options = {}) {
71
- await FsExtra.move(src, dest, options);
71
+ await FsExtra.move(src, dest, options);
72
72
  }
73
- async function readFile(path, options = { encoding: 'utf-8', flag: 'r' }) {
74
- return await FilesystemPromises.readFile(path, options);
73
+ async function readFile(path, options = {
74
+ encoding: "utf-8",
75
+ flag: "r"
76
+ }) {
77
+ return await FilesystemPromises.readFile(path, options);
75
78
  }
76
- async function writeFile(path, data, options = { encoding: 'utf-8', flag: 'w' }) {
77
- return await FilesystemPromises.writeFile(path, data, options);
79
+ async function writeFile(path, data, options = {
80
+ encoding: "utf-8",
81
+ flag: "w"
82
+ }) {
83
+ return await FilesystemPromises.writeFile(path, data, options);
78
84
  }
79
85
  async function readJsonFile(path) {
80
- const content = await readFile(path, { encoding: 'utf8' });
81
- return JSON.parse(content);
86
+ const content = await readFile(path, { encoding: "utf8" });
87
+ return JSON.parse(content);
82
88
  }
83
89
  async function writeJsonFile(path, data) {
84
- return writeFile(path, JSON.stringify(data, null, 4));
90
+ return writeFile(path, JSON.stringify(data, null, 4));
85
91
  }
86
92
  async function glob(pattern, options) {
87
- let _options = options;
88
- if (options?.dot == null) {
89
- _options = { ...options, dot: true };
90
- }
91
- return glob$1.glob(pattern, _options || {});
92
- }
93
- async function archived(path$1, name, glob = '**/*') {
94
- return new Promise((resolve$1, reject) => {
95
- try {
96
- const archivePath = resolve(path$1, `${name}.zip`);
97
- const output = createWriteStream(archivePath);
98
- const _archiver = archiver('zip', { zlib: { level: 9 } });
99
- output.on('close', () => resolve$1(archivePath));
100
- _archiver.on('error', () => (err) => reject(err));
101
- _archiver.pipe(output);
102
- _archiver.glob(glob, {
103
- ignore: [`${name}.zip`],
104
- cwd: path$1,
105
- });
106
- _archiver.finalize();
107
- }
108
- catch (err) {
109
- reject(err);
110
- }
111
- });
93
+ let _options = options;
94
+ if (options?.dot == null) _options = {
95
+ ...options,
96
+ dot: true
97
+ };
98
+ return glob$1.glob(pattern, _options || {});
99
+ }
100
+ async function archived(path, name, glob = "**/*") {
101
+ return new Promise((resolve$1, reject) => {
102
+ try {
103
+ const archivePath = resolve(path, `${name}.zip`);
104
+ const output = createWriteStream(archivePath);
105
+ const _archiver = archiver("zip", { zlib: { level: 9 } });
106
+ output.on("close", () => resolve$1(archivePath));
107
+ _archiver.on("error", () => (err) => reject(err));
108
+ _archiver.pipe(output);
109
+ _archiver.glob(glob, {
110
+ ignore: [`${name}.zip`],
111
+ cwd: path
112
+ });
113
+ _archiver.finalize();
114
+ } catch (err) {
115
+ reject(err);
116
+ }
117
+ });
112
118
  }
113
119
  async function unlink(path) {
114
- if (await exists(path)) {
115
- await FilesystemPromises.unlink(path);
116
- }
120
+ if (await exists(path)) await FilesystemPromises.unlink(path);
117
121
  }
118
122
  async function readdir(path) {
119
- return await FilesystemPromises.readdir(path);
123
+ return await FilesystemPromises.readdir(path);
120
124
  }
121
125
  async function stat(path) {
122
- return await FilesystemPromises.stat(path);
126
+ return await FilesystemPromises.stat(path);
123
127
  }
124
128
  async function chmod(path, mode) {
125
- return await FilesystemPromises.chmod(path, mode);
129
+ return await FilesystemPromises.chmod(path, mode);
126
130
  }
127
131
  const watch = chokidar.watch;
128
- async function decompressGzip(file, destination, mode = 0o755) {
129
- const unzip = createGunzip();
130
- const readStream = createReadStream(file);
131
- const writeStream = createWriteStream(destination, { mode });
132
- await pipeline(readStream, unzip, writeStream);
132
+ async function decompressGzip(file, destination, mode = 493) {
133
+ const unzip = createGunzip();
134
+ await pipeline(createReadStream(file), unzip, createWriteStream(destination, { mode }));
133
135
  }
134
136
  async function extractTar(file, cwd, mode) {
135
- await tar.extract({ cwd, file, mode });
136
- }
137
-
138
- export { archived, chmod, decompressGzip, exists, extractTar, glob, isDirectory, isExecutable, mkdir, move, readFile, readJsonFile, readdir, rm, stat, tapIntoTmp, unlink, watch, writeFile, writeJsonFile };
137
+ await tar.extract({
138
+ cwd,
139
+ file,
140
+ mode
141
+ });
142
+ }
143
+ //#endregion
144
+ export { archived, chmod, decompressGzip, exists, extractTar, filesystem_exports, glob, isDirectory, isExecutable, mkdir, move, readFile, readJsonFile, readdir, rm, stat, tapIntoTmp, unlink, watch, writeFile, writeJsonFile };
package/dist/node/form.js CHANGED
@@ -1,45 +1,30 @@
1
- import { FormData, File } from 'formdata-node';
2
- import { fileFromPath } from 'formdata-node/file-from-path';
3
-
1
+ import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
+ import { File, FormData } from "formdata-node";
3
+ import { fileFromPath } from "formdata-node/file-from-path";
4
+ //#region lib/node/form.ts
5
+ var form_exports = /* @__PURE__ */ __exportAll({
6
+ convert: () => convert,
7
+ file: () => file
8
+ });
4
9
  const file = fileFromPath;
5
10
  function convert(source, form = new FormData(), parentKey = null) {
6
- source = source || {};
7
- for (const key in source) {
8
- if (Object.prototype.hasOwnProperty.call(source, key)) {
9
- append(form, toKey(parentKey, key), source[key]);
10
- }
11
- }
12
- return form;
11
+ source = source || {};
12
+ for (const key in source) if (Object.prototype.hasOwnProperty.call(source, key)) append(form, toKey(parentKey, key), source[key]);
13
+ return form;
13
14
  }
14
15
  function append(form, key, value) {
15
- if (Array.isArray(value)) {
16
- return Array.from(value.keys()).forEach(index => append(form, toKey(key, index.toString()), value[index]));
17
- }
18
- else if (value instanceof Date) {
19
- return form.append(key, value.toISOString());
20
- }
21
- else if (value instanceof File) {
22
- return form.append(key, value, value.name);
23
- }
24
- else if (value instanceof Blob) {
25
- return form.append(key, value);
26
- }
27
- else if (typeof value === 'boolean') {
28
- return form.append(key, value ? '1' : '0');
29
- }
30
- else if (typeof value === 'string') {
31
- return form.append(key, value);
32
- }
33
- else if (typeof value === 'number') {
34
- return form.append(key, `${value}`);
35
- }
36
- else if (value === null || value === undefined) {
37
- return form.append(key, '');
38
- }
39
- convert(value, form, key);
16
+ if (Array.isArray(value)) return Array.from(value.keys()).forEach((index) => append(form, toKey(key, index.toString()), value[index]));
17
+ else if (value instanceof Date) return form.append(key, value.toISOString());
18
+ else if (value instanceof File) return form.append(key, value, value.name);
19
+ else if (value instanceof Blob) return form.append(key, value);
20
+ else if (typeof value === "boolean") return form.append(key, value ? "1" : "0");
21
+ else if (typeof value === "string") return form.append(key, value);
22
+ else if (typeof value === "number") return form.append(key, `${value}`);
23
+ else if (value === null || value === void 0) return form.append(key, "");
24
+ convert(value, form, key);
40
25
  }
41
26
  function toKey(parent, key) {
42
- return parent ? `${parent}[${key}]` : key;
27
+ return parent ? `${parent}[${key}]` : key;
43
28
  }
44
-
45
- export { convert, file };
29
+ //#endregion
30
+ export { convert, file, form_exports };
package/dist/node/git.js CHANGED
@@ -1,52 +1,47 @@
1
- import process from 'node:process';
2
- import git from 'simple-git';
3
- import { exec } from './system.js';
4
-
1
+ import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
+ import { exec } from "./system.js";
3
+ import process from "node:process";
4
+ import git from "simple-git";
5
+ //#region lib/node/git.ts
6
+ var git_exports = /* @__PURE__ */ __exportAll({
7
+ assertGitExists: () => assertGitExists,
8
+ binaryExists: () => binaryExists,
9
+ clone: () => clone
10
+ });
5
11
  async function binaryExists() {
6
- try {
7
- await exec('git', ['--version']);
8
- return true;
9
- }
10
- catch {
11
- return false;
12
- }
12
+ try {
13
+ await exec("git", ["--version"]);
14
+ return true;
15
+ } catch {
16
+ return false;
17
+ }
13
18
  }
14
19
  async function assertGitExists() {
15
- if (!(await binaryExists())) {
16
- throw new Error('Git is required for the setup to continue.');
17
- }
20
+ if (!await binaryExists()) throw new Error("Git is required for the setup to continue.");
18
21
  }
19
22
  async function clone(cloneOptions) {
20
- await assertGitExists();
21
- const { url, destination, shallow, latestTag } = cloneOptions;
22
- const [repository, branch] = url.split('#');
23
- const options = { '--recurse-submodules': null };
24
- // ignore latest tag if branch is provided
25
- if (branch) {
26
- options['--branch'] = branch;
27
- }
28
- if (shallow && latestTag) {
29
- throw new Error('Cannot get a shallow clone of the latest branch.');
30
- }
31
- if (shallow) {
32
- options['--depth'] = 1;
33
- }
34
- const { GIT_ASKPASS, SSH_ASKPASS, ...env } = process.env;
35
- await git({ config: [] })
36
- .env({ ...env, GIT_TERMINAL_PROMPT: '0' })
37
- .clone(repository, destination, options);
38
- if (latestTag) {
39
- const localRepo = git(destination);
40
- const latestTag = await getLocalLatestTag(localRepo, url);
41
- await localRepo.checkout(latestTag);
42
- }
23
+ await assertGitExists();
24
+ const { url, destination, shallow, latestTag } = cloneOptions;
25
+ const [repository, branch] = url.split("#");
26
+ const options = { "--recurse-submodules": null };
27
+ if (branch) options["--branch"] = branch;
28
+ if (shallow && latestTag) throw new Error("Cannot get a shallow clone of the latest branch.");
29
+ if (shallow) options["--depth"] = 1;
30
+ const { GIT_ASKPASS, SSH_ASKPASS, ...env } = process.env;
31
+ await git({ config: [] }).env({
32
+ ...env,
33
+ GIT_TERMINAL_PROMPT: "0"
34
+ }).clone(repository, destination, options);
35
+ if (latestTag) {
36
+ const localRepo = git(destination);
37
+ const latestTag = await getLocalLatestTag(localRepo, url);
38
+ await localRepo.checkout(latestTag);
39
+ }
43
40
  }
44
41
  async function getLocalLatestTag(repository, url) {
45
- const latest = (await repository.tags()).latest;
46
- if (!latest) {
47
- throw new Error(`Couldn't infer the latest tag from ${url}`);
48
- }
49
- return latest;
42
+ const latest = (await repository.tags()).latest;
43
+ if (!latest) throw new Error(`Couldn't infer the latest tag from ${url}`);
44
+ return latest;
50
45
  }
51
-
52
- export { assertGitExists, binaryExists, clone };
46
+ //#endregion
47
+ export { assertGitExists, binaryExists, clone, git_exports };
@@ -1,11 +1,14 @@
1
+ import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
+ //#region lib/node/github.ts
3
+ var github_exports = /* @__PURE__ */ __exportAll({ parseRepositoryReference: () => parseRepositoryReference });
1
4
  function parseRepositoryReference(reference) {
2
- const url = new URL(reference);
3
- const [, user, repo, ...repoPath] = url.pathname.split('/');
4
- return {
5
- baseUrl: `${url.origin}/${user}/${repo}`,
6
- branch: url.hash ? url.hash.slice(1) : undefined,
7
- path: repoPath.length > 0 ? repoPath.join('/') : undefined,
8
- };
5
+ const url = new URL(reference);
6
+ const [, user, repo, ...repoPath] = url.pathname.split("/");
7
+ return {
8
+ baseUrl: `${url.origin}/${user}/${repo}`,
9
+ branch: url.hash ? url.hash.slice(1) : void 0,
10
+ path: repoPath.length > 0 ? repoPath.join("/") : void 0
11
+ };
9
12
  }
10
-
11
- export { parseRepositoryReference };
13
+ //#endregion
14
+ export { github_exports, parseRepositoryReference };