@shopify/cli-kit 3.34.0 → 3.36.0
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/dist/content-tokens.js +1 -1
- package/dist/content-tokens.js.map +1 -1
- package/dist/error.js +2 -2
- package/dist/error.js.map +1 -1
- package/dist/git.js +2 -2
- package/dist/git.js.map +1 -1
- package/dist/index.d.ts +0 -6
- package/dist/index.js +0 -6
- package/dist/index.js.map +1 -1
- package/dist/metadata.d.ts +1 -1
- package/dist/metadata.js.map +1 -1
- package/dist/monorail.d.ts +1 -1
- package/dist/monorail.js +1 -1
- package/dist/monorail.js.map +1 -1
- package/dist/output.js +3 -7
- package/dist/output.js.map +1 -1
- package/dist/plugins.d.ts +1 -1
- package/dist/plugins.js.map +1 -1
- package/dist/{typing → private/common/ts}/deep-required.d.ts +3 -3
- package/dist/{typing → private/common/ts}/deep-required.js +0 -0
- package/dist/private/common/ts/deep-required.js.map +1 -0
- package/dist/{typing → private/common/ts}/overloaded-parameters.d.ts +0 -0
- package/dist/{typing → private/common/ts}/overloaded-parameters.js +0 -0
- package/dist/private/common/ts/overloaded-parameters.js.map +1 -0
- package/dist/private/node/api/graphql.js +2 -3
- package/dist/private/node/api/graphql.js.map +1 -1
- package/dist/private/node/api/headers.d.ts +11 -2
- package/dist/private/node/api/headers.js +29 -3
- package/dist/private/node/api/headers.js.map +1 -1
- package/dist/private/node/api/rest.d.ts +5 -3
- package/dist/private/node/api/rest.js +8 -7
- package/dist/private/node/api/rest.js.map +1 -1
- package/dist/private/node/constants.d.ts +42 -0
- package/dist/private/node/constants.js +58 -0
- package/dist/private/node/constants.js.map +1 -0
- package/dist/private/node/environment/service.js +2 -2
- package/dist/private/node/environment/service.js.map +1 -1
- package/dist/private/node/session/device-authorization.js +1 -1
- package/dist/private/node/session/device-authorization.js.map +1 -1
- package/dist/private/node/session/exchange.js +1 -1
- package/dist/private/node/session/exchange.js.map +1 -1
- package/dist/private/node/session/identity-token-validation.js +1 -1
- package/dist/private/node/session/identity-token-validation.js.map +1 -1
- package/dist/private/node/session/post-auth.js +10 -10
- package/dist/private/node/session/post-auth.js.map +1 -1
- package/dist/private/node/session/store.js +6 -6
- package/dist/private/node/session/store.js.map +1 -1
- package/dist/private/node/session/validate.js +2 -2
- package/dist/private/node/session/validate.js.map +1 -1
- package/dist/private/node/session.js +2 -2
- package/dist/private/node/session.js.map +1 -1
- package/dist/{typing → private/node}/simple-definitions.d.ts +0 -0
- package/dist/{typing → private/node}/simple-definitions.js +0 -0
- package/dist/private/node/simple-definitions.js.map +1 -0
- package/dist/private/node/ui/alert.d.ts +1 -1
- package/dist/private/node/ui/alert.js +2 -2
- package/dist/private/node/ui/alert.js.map +1 -1
- package/dist/private/node/ui/components/Alert.d.ts +5 -0
- package/dist/private/node/ui/components/Alert.js +9 -6
- package/dist/private/node/ui/components/Alert.js.map +1 -1
- package/dist/private/node/ui/components/Alert.test.js +30 -4
- package/dist/private/node/ui/components/Alert.test.js.map +1 -1
- package/dist/private/node/ui/components/AutocompletePrompt.d.ts +12 -0
- package/dist/private/node/ui/components/AutocompletePrompt.js +111 -0
- package/dist/private/node/ui/components/AutocompletePrompt.js.map +1 -0
- package/dist/private/node/ui/components/AutocompletePrompt.test.d.ts +1 -0
- package/dist/private/node/ui/components/AutocompletePrompt.test.js +473 -0
- package/dist/private/node/ui/components/AutocompletePrompt.test.js.map +1 -0
- package/dist/private/node/ui/components/Banner.d.ts +0 -1
- package/dist/private/node/ui/components/Banner.js +4 -4
- package/dist/private/node/ui/components/Banner.js.map +1 -1
- package/dist/private/node/ui/components/Banner.test.js +10 -5
- package/dist/private/node/ui/components/Banner.test.js.map +1 -1
- package/dist/private/node/ui/components/FatalError.js +1 -1
- package/dist/private/node/ui/components/FatalError.js.map +1 -1
- package/dist/private/node/ui/components/FatalError.test.js +4 -8
- package/dist/private/node/ui/components/FatalError.test.js.map +1 -1
- package/dist/private/node/ui/components/{Table.d.ts → Prompts/InfoTable.d.ts} +2 -2
- package/dist/private/node/ui/components/{Table.js → Prompts/InfoTable.js} +6 -6
- package/dist/private/node/ui/components/Prompts/InfoTable.js.map +1 -0
- package/dist/private/node/ui/components/SelectInput.d.ts +9 -2
- package/dist/private/node/ui/components/SelectInput.js +96 -52
- package/dist/private/node/ui/components/SelectInput.js.map +1 -1
- package/dist/private/node/ui/components/SelectInput.test.js +140 -54
- package/dist/private/node/ui/components/SelectInput.test.js.map +1 -1
- package/dist/private/node/ui/components/SelectPrompt.d.ts +6 -4
- package/dist/private/node/ui/components/SelectPrompt.js +18 -11
- package/dist/private/node/ui/components/SelectPrompt.js.map +1 -1
- package/dist/private/node/ui/components/SelectPrompt.test.js +113 -23
- package/dist/private/node/ui/components/SelectPrompt.test.js.map +1 -1
- package/dist/private/node/ui/components/Table/Column.d.ts +5 -0
- package/dist/private/node/ui/components/Table/Column.js +2 -0
- package/dist/private/node/ui/components/Table/Column.js.map +1 -0
- package/dist/private/node/ui/components/Table/Row.d.ts +12 -0
- package/dist/private/node/ui/components/Table/Row.js +24 -0
- package/dist/private/node/ui/components/Table/Row.js.map +1 -0
- package/dist/private/node/ui/components/Table/ScalarDict.d.ts +5 -0
- package/dist/private/node/ui/components/Table/ScalarDict.js +2 -0
- package/dist/private/node/ui/components/Table/ScalarDict.js.map +1 -0
- package/dist/private/node/ui/components/Table/Table.d.ts +12 -0
- package/dist/private/node/ui/components/Table/Table.js +30 -0
- package/dist/private/node/ui/components/Table/Table.js.map +1 -0
- package/dist/private/node/ui/components/Table/Table.test.d.ts +1 -0
- package/dist/private/node/ui/components/Table/Table.test.js +41 -0
- package/dist/private/node/ui/components/Table/Table.test.js.map +1 -0
- package/dist/private/node/ui/components/Tasks.d.ts +6 -5
- package/dist/private/node/ui/components/Tasks.js +32 -11
- package/dist/private/node/ui/components/Tasks.js.map +1 -1
- package/dist/private/node/ui/components/Tasks.test.js +55 -9
- package/dist/private/node/ui/components/Tasks.test.js.map +1 -1
- package/dist/private/node/ui/components/TextInput.d.ts +4 -1
- package/dist/private/node/ui/components/TextInput.js +22 -13
- package/dist/private/node/ui/components/TextInput.js.map +1 -1
- package/dist/private/node/ui/components/TextInput.test.js +47 -40
- package/dist/private/node/ui/components/TextInput.test.js.map +1 -1
- package/dist/private/node/ui/components/TextPrompt.d.ts +3 -1
- package/dist/private/node/ui/components/TextPrompt.js +28 -15
- package/dist/private/node/ui/components/TextPrompt.js.map +1 -1
- package/dist/private/node/ui/components/TextPrompt.test.js +71 -15
- package/dist/private/node/ui/components/TextPrompt.test.js.map +1 -1
- package/dist/private/node/ui/components/TokenizedText.d.ts +3 -0
- package/dist/private/node/ui/components/TokenizedText.js +33 -1
- package/dist/private/node/ui/components/TokenizedText.js.map +1 -1
- package/dist/private/node/ui/utilities.d.ts +2 -0
- package/dist/private/node/ui/utilities.js +6 -0
- package/dist/private/node/ui/utilities.js.map +1 -0
- package/dist/public/common/string.d.ts +11 -0
- package/dist/public/common/string.js +21 -0
- package/dist/public/common/string.js.map +1 -1
- package/dist/{typing → public/common/ts}/pick-by-prefix.d.ts +4 -3
- package/dist/{typing → public/common/ts}/pick-by-prefix.js +0 -0
- package/dist/public/common/ts/pick-by-prefix.js.map +1 -0
- package/dist/public/common/version.d.ts +1 -0
- package/dist/public/common/version.js +2 -0
- package/dist/public/common/version.js.map +1 -0
- package/dist/public/node/analytics.js +2 -2
- package/dist/public/node/analytics.js.map +1 -1
- package/dist/public/node/api/admin.d.ts +4 -1
- package/dist/public/node/api/admin.js +5 -4
- package/dist/public/node/api/admin.js.map +1 -1
- package/dist/public/node/api/http.d.ts +0 -0
- package/dist/public/node/api/http.js +2 -0
- package/dist/public/node/api/http.js.map +1 -0
- package/dist/public/node/api/oxygen.js +1 -1
- package/dist/public/node/api/oxygen.js.map +1 -1
- package/dist/public/node/archiver.js +2 -1
- package/dist/public/node/archiver.js.map +1 -1
- package/dist/public/node/cli.js +6 -6
- package/dist/public/node/cli.js.map +1 -1
- package/dist/public/node/dot-env.js +2 -2
- package/dist/public/node/dot-env.js.map +1 -1
- package/dist/public/node/environment/local.js +17 -17
- package/dist/public/node/environment/local.js.map +1 -1
- package/dist/public/node/environment/spin.js +6 -6
- package/dist/public/node/environment/spin.js.map +1 -1
- package/dist/public/node/error-handler.js +13 -10
- package/dist/public/node/error-handler.js.map +1 -1
- package/dist/public/node/framework.js +2 -2
- package/dist/public/node/framework.js.map +1 -1
- package/dist/public/node/fs.d.ts +241 -4
- package/dist/public/node/fs.js +366 -2
- package/dist/public/node/fs.js.map +1 -1
- package/dist/public/node/git.d.ts +90 -0
- package/dist/public/node/git.js +174 -0
- package/dist/public/node/git.js.map +1 -0
- package/dist/public/node/github.js +1 -1
- package/dist/public/node/github.js.map +1 -1
- package/dist/{http/fetch.d.ts → public/node/http.d.ts} +18 -7
- package/dist/{http/fetch.js → public/node/http.js} +21 -8
- package/dist/public/node/http.js.map +1 -0
- package/dist/public/node/liquid.js +9 -9
- package/dist/public/node/liquid.js.map +1 -1
- package/dist/public/node/node-package-manager.d.ts +20 -9
- package/dist/public/node/node-package-manager.js +19 -25
- package/dist/public/node/node-package-manager.js.map +1 -1
- package/dist/public/node/path.d.ts +22 -0
- package/dist/{path.js → public/node/path.js} +8 -20
- package/dist/public/node/path.js.map +1 -0
- package/dist/public/node/presets.js +5 -5
- package/dist/public/node/presets.js.map +1 -1
- package/dist/public/node/ruby.js +29 -33
- package/dist/public/node/ruby.js.map +1 -1
- package/dist/public/node/session.js +2 -2
- package/dist/public/node/session.js.map +1 -1
- package/dist/public/node/ui.d.ts +63 -9
- package/dist/public/node/ui.js +83 -8
- package/dist/public/node/ui.js.map +1 -1
- package/dist/public/node/vscode.js +8 -8
- package/dist/public/node/vscode.js.map +1 -1
- package/dist/secure-store.js +4 -4
- package/dist/secure-store.js.map +1 -1
- package/dist/store.d.ts +10 -10
- package/dist/store.js +21 -22
- package/dist/store.js.map +1 -1
- package/dist/testing/store.js +3 -3
- package/dist/testing/store.js.map +1 -1
- package/dist/testing/ui.d.ts +4 -1
- package/dist/testing/ui.js +24 -1
- package/dist/testing/ui.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/ui/executor.d.ts +2 -14
- package/dist/ui/executor.js +38 -72
- package/dist/ui/executor.js.map +1 -1
- package/dist/ui.js +9 -26
- package/dist/ui.js.map +1 -1
- package/package.json +4 -6
- package/dist/constants.d.ts +0 -48
- package/dist/constants.js +0 -67
- package/dist/constants.js.map +0 -1
- package/dist/file.d.ts +0 -98
- package/dist/file.js +0 -216
- package/dist/file.js.map +0 -1
- package/dist/http/fetch.js.map +0 -1
- package/dist/http/formdata.d.ts +0 -3
- package/dist/http/formdata.js +0 -6
- package/dist/http/formdata.js.map +0 -1
- package/dist/http.d.ts +0 -26
- package/dist/http.js +0 -31
- package/dist/http.js.map +0 -1
- package/dist/npm.d.ts +0 -27
- package/dist/npm.js +0 -20
- package/dist/npm.js.map +0 -1
- package/dist/path.d.ts +0 -25
- package/dist/path.js.map +0 -1
- package/dist/private/node/ui/components/Table.js.map +0 -1
- package/dist/typing/deep-required.js.map +0 -1
- package/dist/typing/overloaded-parameters.js.map +0 -1
- package/dist/typing/pick-by-prefix.js.map +0 -1
- package/dist/typing/simple-definitions.js.map +0 -1
- package/dist/ui/inquirer/autocomplete.d.ts +0 -11
- package/dist/ui/inquirer/autocomplete.js +0 -110
- package/dist/ui/inquirer/autocomplete.js.map +0 -1
- package/dist/ui/inquirer/input.d.ts +0 -16
- package/dist/ui/inquirer/input.js +0 -45
- package/dist/ui/inquirer/input.js.map +0 -1
- package/dist/ui/inquirer/password.d.ts +0 -7
- package/dist/ui/inquirer/password.js +0 -8
- package/dist/ui/inquirer/password.js.map +0 -1
- package/dist/ui/inquirer/select.d.ts +0 -14
- package/dist/ui/inquirer/select.js +0 -26
- package/dist/ui/inquirer/select.js.map +0 -1
package/dist/file.js
DELETED
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
import { content as outputContent, token, debug } from './output.js';
|
|
2
|
-
import { copy as fsCopy, ensureFile as fsEnsureFile, ensureFileSync as fsEnsureFileSync, remove as fsRemove, removeSync as fsRemoveSync, move as fsMove,
|
|
3
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
4
|
-
// @ts-ignore
|
|
5
|
-
} from 'fs-extra/esm';
|
|
6
|
-
import { temporaryDirectoryTask } from 'tempy';
|
|
7
|
-
import { sep, join, extname } from 'pathe';
|
|
8
|
-
import { mkdirSync as fsMkdirSync, readFileSync as fsReadFileSync, writeFileSync as fsWriteFileSync, appendFileSync as fsAppendFileSync, statSync as fsStatSync, createReadStream as fsCreateReadStream, constants as fsConstants, } from 'fs';
|
|
9
|
-
import { mkdir as fsMkdir, writeFile as fsWriteFile, readFile as fsReadFile, realpath as fsRealPath, appendFile as fsAppendFile, mkdtemp as fsMkdtemp, stat as fsStat, lstat as fsLstat, chmod as fsChmod, access as fsAccess, } from 'fs/promises';
|
|
10
|
-
const DEFAULT_PRETTIER_CONFIG = {
|
|
11
|
-
arrowParens: 'always',
|
|
12
|
-
singleQuote: true,
|
|
13
|
-
bracketSpacing: false,
|
|
14
|
-
trailingComma: 'all',
|
|
15
|
-
};
|
|
16
|
-
export function stripUp(path, strip) {
|
|
17
|
-
const parts = path.split(sep);
|
|
18
|
-
return join(...parts.slice(strip));
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Creates a temporary directory and ties its lifecycle to the lifecycle of the callback.
|
|
22
|
-
* @param callback - The callback that receives the temporary directory.
|
|
23
|
-
*/
|
|
24
|
-
export async function inTemporaryDirectory(callback) {
|
|
25
|
-
return temporaryDirectoryTask(callback);
|
|
26
|
-
}
|
|
27
|
-
export async function read(path, options = { encoding: 'utf8' }) {
|
|
28
|
-
debug(outputContent `Reading the content of file at ${token.path(path)}...`);
|
|
29
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
30
|
-
// @ts-ignore
|
|
31
|
-
return fsReadFile(path, options);
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Given a path, it determines the actual path. This is useful when working
|
|
35
|
-
* with paths that represent symlinks.
|
|
36
|
-
* @param path - Path whose real path will be returned.
|
|
37
|
-
*/
|
|
38
|
-
export async function realpath(path) {
|
|
39
|
-
return fsRealPath(path);
|
|
40
|
-
}
|
|
41
|
-
export function readSync(path, options = { encoding: 'utf-8' }) {
|
|
42
|
-
debug(outputContent `Sync-reading the content of file at ${token.path(path)}...`);
|
|
43
|
-
const content = fsReadFileSync(path, options);
|
|
44
|
-
return content.toString();
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Copies a file
|
|
48
|
-
* @param from - Path to the directory or file to be copied.
|
|
49
|
-
* @param to - Destination path.
|
|
50
|
-
*/
|
|
51
|
-
export async function copy(from, to) {
|
|
52
|
-
debug(outputContent `Copying file from ${token.path(from)} to ${token.path(to)}...`);
|
|
53
|
-
await fsCopy(from, to);
|
|
54
|
-
}
|
|
55
|
-
export async function touch(path) {
|
|
56
|
-
debug(outputContent `Creating an empty file at ${token.path(path)}...`);
|
|
57
|
-
await fsEnsureFile(path);
|
|
58
|
-
}
|
|
59
|
-
export async function appendFile(path, content) {
|
|
60
|
-
debug(outputContent `Appending the following content to ${token.path(path)}:
|
|
61
|
-
${content
|
|
62
|
-
.split('\n')
|
|
63
|
-
.map((line) => ` ${line}`)
|
|
64
|
-
.join('\n')}
|
|
65
|
-
`);
|
|
66
|
-
await fsAppendFile(path, content);
|
|
67
|
-
}
|
|
68
|
-
export function touchSync(path) {
|
|
69
|
-
debug(outputContent `Creating an empty file at ${token.path(path)}...`);
|
|
70
|
-
fsEnsureFileSync(path);
|
|
71
|
-
}
|
|
72
|
-
export async function write(path, data) {
|
|
73
|
-
debug(outputContent `Writing some content to file at ${token.path(path)}...`);
|
|
74
|
-
await fsWriteFile(path, data, { encoding: 'utf8' });
|
|
75
|
-
}
|
|
76
|
-
export function writeSync(path, data) {
|
|
77
|
-
debug(outputContent `File-writing some content to file at ${token.path(path)}...`);
|
|
78
|
-
fsWriteFileSync(path, data);
|
|
79
|
-
}
|
|
80
|
-
export async function append(path, data) {
|
|
81
|
-
await fsAppendFile(path, data);
|
|
82
|
-
}
|
|
83
|
-
export function appendSync(path, data) {
|
|
84
|
-
fsAppendFileSync(path, data);
|
|
85
|
-
}
|
|
86
|
-
export async function mkdir(path) {
|
|
87
|
-
debug(outputContent `Creating directory at ${token.path(path)}...`);
|
|
88
|
-
await fsMkdir(path, { recursive: true });
|
|
89
|
-
}
|
|
90
|
-
export function mkdirSync(path) {
|
|
91
|
-
debug(outputContent `Sync-creating directory at ${token.path(path)}...`);
|
|
92
|
-
fsMkdirSync(path, { recursive: true });
|
|
93
|
-
}
|
|
94
|
-
export async function remove(path) {
|
|
95
|
-
debug(outputContent `Removing file at ${token.path(path)}...`);
|
|
96
|
-
await fsRemove(path);
|
|
97
|
-
}
|
|
98
|
-
export function removeSync(path) {
|
|
99
|
-
debug(outputContent `Sync-removing file at ${token.path(path)}...`);
|
|
100
|
-
fsRemoveSync(path);
|
|
101
|
-
}
|
|
102
|
-
export async function rmdir(path, { force } = {}) {
|
|
103
|
-
const { default: del } = await import('del');
|
|
104
|
-
debug(outputContent `Removing directory at ${token.path(path)}...`);
|
|
105
|
-
await del(path, { force });
|
|
106
|
-
}
|
|
107
|
-
export async function mkTmpDir() {
|
|
108
|
-
debug(outputContent `Creating a temporary directory...`);
|
|
109
|
-
const directory = await fsMkdtemp('tmp-');
|
|
110
|
-
return directory;
|
|
111
|
-
}
|
|
112
|
-
export async function isDirectory(path) {
|
|
113
|
-
debug(outputContent `Checking if ${token.path(path)} is a directory...`);
|
|
114
|
-
return (await fsLstat(path)).isDirectory();
|
|
115
|
-
}
|
|
116
|
-
export async function size(path) {
|
|
117
|
-
debug(outputContent `Getting the size of file file at ${token.path(path)}...`);
|
|
118
|
-
return (await fsStat(path)).size;
|
|
119
|
-
}
|
|
120
|
-
export function sizeSync(path) {
|
|
121
|
-
debug(outputContent `Sync-getting the size of file file at ${token.path(path)}...`);
|
|
122
|
-
return fsStatSync(path).size;
|
|
123
|
-
}
|
|
124
|
-
export function createReadStream(path) {
|
|
125
|
-
return fsCreateReadStream(path);
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Returns the Date object for the last modification of a file.
|
|
129
|
-
* @param path - Path to the directory or file.
|
|
130
|
-
* @returns A unix timestamp.
|
|
131
|
-
*/
|
|
132
|
-
export async function lastUpdated(path) {
|
|
133
|
-
debug(outputContent `Getting last updated timestamp for file at ${token.path(path)}...`);
|
|
134
|
-
return (await fsStat(path)).ctime;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Returns the unix timestamp of the last modification of a file.
|
|
138
|
-
* @param path - Path to the directory or file.
|
|
139
|
-
* @returns A unix timestamp.
|
|
140
|
-
*/
|
|
141
|
-
export async function lastUpdatedTimestamp(path) {
|
|
142
|
-
try {
|
|
143
|
-
const lastUpdatedDateTime = await lastUpdated(path);
|
|
144
|
-
return lastUpdatedDateTime.getTime();
|
|
145
|
-
// eslint-disable-next-line no-catch-all/no-catch-all
|
|
146
|
-
}
|
|
147
|
-
catch {
|
|
148
|
-
return undefined;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Moves a file.
|
|
153
|
-
* @param src - File to be moved.
|
|
154
|
-
* @param dest - Path to be moved to.
|
|
155
|
-
* @param options - Moving options.
|
|
156
|
-
*/
|
|
157
|
-
export async function move(src, dest, options = {}) {
|
|
158
|
-
await fsMove(src, dest, options);
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Changes the permissions of a directory or file.
|
|
162
|
-
* @param path - Path to the file or directory whose permissions will be modified.
|
|
163
|
-
* @param mode - Permissions to set to the file or directory.
|
|
164
|
-
*/
|
|
165
|
-
export async function chmod(path, mode) {
|
|
166
|
-
await fsChmod(path, mode);
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Checks if a file has executable permissions.
|
|
170
|
-
* @param path - Path to the file whose permissions will be checked.
|
|
171
|
-
*/
|
|
172
|
-
export async function hasExecutablePermissions(path) {
|
|
173
|
-
try {
|
|
174
|
-
await fsAccess(path, fsConstants.X_OK);
|
|
175
|
-
return true;
|
|
176
|
-
// eslint-disable-next-line no-catch-all/no-catch-all
|
|
177
|
-
}
|
|
178
|
-
catch {
|
|
179
|
-
return false;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Returns true if a file or directory exists
|
|
184
|
-
* @param path - Path to the directory or file.
|
|
185
|
-
* @returns True if it exists.
|
|
186
|
-
*/
|
|
187
|
-
export async function exists(path) {
|
|
188
|
-
try {
|
|
189
|
-
await fsAccess(path);
|
|
190
|
-
return true;
|
|
191
|
-
// eslint-disable-next-line no-catch-all/no-catch-all
|
|
192
|
-
}
|
|
193
|
-
catch {
|
|
194
|
-
return false;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Format a string using prettier. Return the formatted content.
|
|
199
|
-
*/
|
|
200
|
-
export async function format(content, options) {
|
|
201
|
-
const { default: prettier } = await import('prettier');
|
|
202
|
-
const ext = extname(options.path);
|
|
203
|
-
const prettierConfig = {
|
|
204
|
-
...DEFAULT_PRETTIER_CONFIG,
|
|
205
|
-
parser: 'babel',
|
|
206
|
-
};
|
|
207
|
-
switch (ext) {
|
|
208
|
-
case '.html':
|
|
209
|
-
case '.css':
|
|
210
|
-
prettierConfig.parser = ext.slice(1);
|
|
211
|
-
break;
|
|
212
|
-
}
|
|
213
|
-
const formattedContent = await prettier.format(content, prettierConfig);
|
|
214
|
-
return formattedContent;
|
|
215
|
-
}
|
|
216
|
-
//# sourceMappingURL=file.js.map
|
package/dist/file.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file.js","sourceRoot":"","sources":["../src/file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,aAAa,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,aAAa,C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;YACT,cAAc,CAAC,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;YACpC,MAAK;KACR;IAED,MAAM,gBAAgB,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,cAAc,CAAC,CAAA;IAEvE,OAAO,gBAAgB,CAAA;AACzB,CAAC","sourcesContent":["import {content as outputContent, token, debug} from './output.js'\nimport {\n copy as fsCopy,\n ensureFile as fsEnsureFile,\n ensureFileSync as fsEnsureFileSync,\n remove as fsRemove,\n removeSync as fsRemoveSync,\n move as fsMove,\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n} from 'fs-extra/esm'\n\nimport {temporaryDirectoryTask} from 'tempy'\nimport {sep, join, extname} from 'pathe'\nimport {\n mkdirSync as fsMkdirSync,\n readFileSync as fsReadFileSync,\n writeFileSync as fsWriteFileSync,\n appendFileSync as fsAppendFileSync,\n statSync as fsStatSync,\n createReadStream as fsCreateReadStream,\n constants as fsConstants,\n} from 'fs'\nimport {\n mkdir as fsMkdir,\n writeFile as fsWriteFile,\n readFile as fsReadFile,\n realpath as fsRealPath,\n appendFile as fsAppendFile,\n mkdtemp as fsMkdtemp,\n stat as fsStat,\n lstat as fsLstat,\n chmod as fsChmod,\n access as fsAccess,\n} from 'fs/promises'\nimport type {Options} from 'prettier'\n\nconst DEFAULT_PRETTIER_CONFIG: Options = {\n arrowParens: 'always',\n singleQuote: true,\n bracketSpacing: false,\n trailingComma: 'all',\n}\n\nexport function stripUp(path: string, strip: number) {\n const parts = path.split(sep)\n return join(...parts.slice(strip))\n}\n\n/**\n * Creates a temporary directory and ties its lifecycle to the lifecycle of the callback.\n * @param callback - The callback that receives the temporary directory.\n */\nexport async function inTemporaryDirectory<T>(callback: (tmpDir: string) => T | Promise<T>): Promise<T> {\n return temporaryDirectoryTask(callback)\n}\n\n/**\n * It reads a file and returns its content as a string using the\n * utf-8 encoding\n * @param path - Path to the file to read.\n * @returns A promise that resolves with the content of the file.\n */\n\nexport type ReadOptions =\n | undefined\n | {flag?: string | undefined}\n | {\n encoding: BufferEncoding | string\n flag?: string | undefined\n }\nexport async function read(path: string, options?: ReadOptions): Promise<string>\nexport async function read(path: string, options?: ReadOptions): Promise<Buffer>\n\nexport async function read(path: string, options: ReadOptions = {encoding: 'utf8'}): Promise<string | Buffer> {\n debug(outputContent`Reading the content of file at ${token.path(path)}...`)\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return fsReadFile(path, options)\n}\n\n/**\n * Given a path, it determines the actual path. This is useful when working\n * with paths that represent symlinks.\n * @param path - Path whose real path will be returned.\n */\nexport async function realpath(path: string): Promise<string> {\n return fsRealPath(path)\n}\n\nexport function readSync(path: string, options: object = {encoding: 'utf-8'}): string {\n debug(outputContent`Sync-reading the content of file at ${token.path(path)}...`)\n const content = fsReadFileSync(path, options)\n return content.toString()\n}\n\n/**\n * Copies a file\n * @param from - Path to the directory or file to be copied.\n * @param to - Destination path.\n */\nexport async function copy(from: string, to: string): Promise<void> {\n debug(outputContent`Copying file from ${token.path(from)} to ${token.path(to)}...`)\n await fsCopy(from, to)\n}\n\nexport async function touch(path: string): Promise<void> {\n debug(outputContent`Creating an empty file at ${token.path(path)}...`)\n await fsEnsureFile(path)\n}\n\nexport async function appendFile(path: string, content: string): Promise<void> {\n debug(outputContent`Appending the following content to ${token.path(path)}:\n ${content\n .split('\\n')\n .map((line) => ` ${line}`)\n .join('\\n')}\n `)\n await fsAppendFile(path, content)\n}\n\nexport function touchSync(path: string) {\n debug(outputContent`Creating an empty file at ${token.path(path)}...`)\n fsEnsureFileSync(path)\n}\n\nexport async function write(path: string, data: string): Promise<void> {\n debug(outputContent`Writing some content to file at ${token.path(path)}...`)\n await fsWriteFile(path, data, {encoding: 'utf8'})\n}\n\nexport function writeSync(path: string, data: string): void {\n debug(outputContent`File-writing some content to file at ${token.path(path)}...`)\n fsWriteFileSync(path, data)\n}\n\nexport async function append(path: string, data: string): Promise<void> {\n await fsAppendFile(path, data)\n}\n\nexport function appendSync(path: string, data: string): void {\n fsAppendFileSync(path, data)\n}\n\nexport async function mkdir(path: string): Promise<void> {\n debug(outputContent`Creating directory at ${token.path(path)}...`)\n await fsMkdir(path, {recursive: true})\n}\n\nexport function mkdirSync(path: string): void {\n debug(outputContent`Sync-creating directory at ${token.path(path)}...`)\n fsMkdirSync(path, {recursive: true})\n}\n\nexport async function remove(path: string): Promise<void> {\n debug(outputContent`Removing file at ${token.path(path)}...`)\n await fsRemove(path)\n}\n\nexport function removeSync(path: string) {\n debug(outputContent`Sync-removing file at ${token.path(path)}...`)\n fsRemoveSync(path)\n}\n\nexport async function rmdir(path: string, {force}: {force?: boolean} = {}): Promise<void> {\n const {default: del} = await import('del')\n debug(outputContent`Removing directory at ${token.path(path)}...`)\n await del(path, {force})\n}\n\nexport async function mkTmpDir(): Promise<string> {\n debug(outputContent`Creating a temporary directory...`)\n const directory = await fsMkdtemp('tmp-')\n return directory\n}\n\nexport async function isDirectory(path: string): Promise<boolean> {\n debug(outputContent`Checking if ${token.path(path)} is a directory...`)\n return (await fsLstat(path)).isDirectory()\n}\n\nexport async function size(path: string): Promise<number> {\n debug(outputContent`Getting the size of file file at ${token.path(path)}...`)\n return (await fsStat(path)).size\n}\n\nexport function sizeSync(path: string): number {\n debug(outputContent`Sync-getting the size of file file at ${token.path(path)}...`)\n return fsStatSync(path).size\n}\n\nexport function createReadStream(path: string) {\n return fsCreateReadStream(path)\n}\n\n/**\n * Returns the Date object for the last modification of a file.\n * @param path - Path to the directory or file.\n * @returns A unix timestamp.\n */\nexport async function lastUpdated(path: string): Promise<Date> {\n debug(outputContent`Getting last updated timestamp for file at ${token.path(path)}...`)\n return (await fsStat(path)).ctime\n}\n\n/**\n * Returns the unix timestamp of the last modification of a file.\n * @param path - Path to the directory or file.\n * @returns A unix timestamp.\n */\nexport async function lastUpdatedTimestamp(path: string): Promise<number | undefined> {\n try {\n const lastUpdatedDateTime = await lastUpdated(path)\n return lastUpdatedDateTime.getTime()\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return undefined\n }\n}\n\n/**\n * Moves a file.\n * @param src - File to be moved.\n * @param dest - Path to be moved to.\n * @param options - Moving options.\n */\nexport async function move(src: string, dest: string, options: {overwrite?: boolean} = {}): Promise<void> {\n await fsMove(src, dest, options)\n}\n\n/**\n * Changes the permissions of a directory or file.\n * @param path - Path to the file or directory whose permissions will be modified.\n * @param mode - Permissions to set to the file or directory.\n */\nexport async function chmod(path: string, mode: number | string): Promise<void> {\n await fsChmod(path, mode)\n}\n\n/**\n * Checks if a file has executable permissions.\n * @param path - Path to the file whose permissions will be checked.\n */\nexport async function hasExecutablePermissions(path: string): Promise<boolean> {\n try {\n await fsAccess(path, fsConstants.X_OK)\n return true\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\n/**\n * Returns true if a file or directory exists\n * @param path - Path to the directory or file.\n * @returns True if it exists.\n */\nexport async function exists(path: string): Promise<boolean> {\n try {\n await fsAccess(path)\n return true\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\n/**\n * Format a string using prettier. Return the formatted content.\n */\nexport async function format(content: string, options: {path: string}) {\n const {default: prettier} = await import('prettier')\n\n const ext = extname(options.path)\n const prettierConfig: Options = {\n ...DEFAULT_PRETTIER_CONFIG,\n parser: 'babel',\n }\n\n switch (ext) {\n case '.html':\n case '.css':\n prettierConfig.parser = ext.slice(1)\n break\n }\n\n const formattedContent = await prettier.format(content, prettierConfig)\n\n return formattedContent\n}\n"]}
|
package/dist/http/fetch.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/http/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,EAAC,OAAO,EAAE,KAAK,EAAC,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAC,YAAY,EAAE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ent} from '../http.js'\nimport {content, debug} from '../output.js'\nimport {buildHeaders, sanitizedHeadersOutput} from '../private/node/api/headers.js'\nimport nodeFetch from 'node-fetch'\nimport {performance} from 'perf_hooks'\nimport type {RequestInfo, RequestInit} from 'node-fetch'\n\ntype Response = ReturnType<typeof nodeFetch>\n/**\n * An interface that abstracts way node-fetch. When Node has built-in\n * support for \"fetch\" in the standard library, we can drop the node-fetch\n * dependency from here.\n * Note that we are exposing types from \"node-fetch\". The reason being is that\n * they are consistent with the Web API so if we drop node-fetch in the future\n * it won't require changes from the callers.\n * @param url - This defines the resource that you wish to fetch.\n * @param init - An object containing any custom settings that you want to apply to the request\n * @returns A promise that resolves with the response.\n */\nexport default async function fetch(url: RequestInfo, init?: RequestInit): Response {\n const response = await nodeFetch(url, init)\n return response\n}\n\n/**\n * A fetch function to use with Shopify services. The function ensures the right\n * TLS configuragion is used based on the environment in which the service is running\n * (e.g. spin)\n */\nexport async function shopifyFetch(url: RequestInfo, init?: RequestInit): Response {\n const options: RequestInit = {\n ...(init ?? {}),\n headers: {\n ...(await buildHeaders()),\n ...(init?.headers ?? {}),\n },\n }\n\n debug(content`\nSending ${options.method ?? 'GET'} request to URL ${url.toString()} and headers:\n${sanitizedHeadersOutput((options?.headers ?? {}) as {[header: string]: string})}\n`)\n const t0 = performance.now()\n const response = await nodeFetch(url, {...init, agent: await httpsAgent()})\n const t1 = performance.now()\n debug(`Request to ${url.toString()} completed with status ${response.status} in ${Math.round(t1 - t0)} ms`)\n return response\n}\n"]}
|
package/dist/http/formdata.d.ts
DELETED
package/dist/http/formdata.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"formdata.js","sourceRoot":"","sources":["../../src/http/formdata.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,WAAW,CAAA;AAEhC,SAAS,QAAQ;IACf,OAAO,IAAI,QAAQ,EAAE,CAAA;AACvB,CAAC;AAED,eAAe,QAAQ,CAAA","sourcesContent":["import FormData from 'form-data'\n\nfunction formData() {\n return new FormData()\n}\n\nexport default formData\n"]}
|
package/dist/http.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import https from 'https';
|
|
3
|
-
export { default as fetch } from './http/fetch.js';
|
|
4
|
-
export { shopifyFetch } from './http/fetch.js';
|
|
5
|
-
export { default as formData } from './http/formdata.js';
|
|
6
|
-
export { createApp, createRouter, IncomingMessage, ServerResponse, CompatibilityEvent, createError, send, sendError, sendRedirect, H3Error, } from 'h3';
|
|
7
|
-
/**
|
|
8
|
-
* This utility function returns the https.Agent to use for a given service. The agent
|
|
9
|
-
* includes the right configuration based on the service's environment. For example,
|
|
10
|
-
* if the service is running in a Spin environment, the attribute "rejectUnauthorized" is
|
|
11
|
-
* set to false
|
|
12
|
-
*/
|
|
13
|
-
export declare function httpsAgent(): Promise<https.Agent>;
|
|
14
|
-
/**
|
|
15
|
-
* Spin stores the CA certificate in the keychain and it should be used when sending HTTP
|
|
16
|
-
* requests to Spin instances. However, Node doesn't read certificates from the Keychain
|
|
17
|
-
* by default, which leads to Shopifolks running into issues that they workaround by setting the
|
|
18
|
-
* NODE_TLS_REJECT_UNAUTHORIZED=0 environment variable, which applies to all the HTTP
|
|
19
|
-
* requests sent from the CLI (context: https://github.com/nodejs/node/issues/39657)
|
|
20
|
-
* This utility function allows controlling the behavior in a per-service level by returning
|
|
21
|
-
* the value of for the "rejectUnauthorized" attribute that's used in the https agent.
|
|
22
|
-
*
|
|
23
|
-
* @returns A promise that resolves with a boolean indicating whether
|
|
24
|
-
* unauthorized requests should be rejected or not.
|
|
25
|
-
*/
|
|
26
|
-
export declare function shouldRejectUnauthorizedRequests(): Promise<boolean>;
|
package/dist/http.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Environment, serviceEnvironment } from './private/node/environment/service.js';
|
|
2
|
-
import https from 'https';
|
|
3
|
-
export { default as fetch } from './http/fetch.js';
|
|
4
|
-
export { shopifyFetch } from './http/fetch.js';
|
|
5
|
-
export { default as formData } from './http/formdata.js';
|
|
6
|
-
export { createApp, createRouter, createError, send, sendError, sendRedirect, H3Error, } from 'h3';
|
|
7
|
-
/**
|
|
8
|
-
* This utility function returns the https.Agent to use for a given service. The agent
|
|
9
|
-
* includes the right configuration based on the service's environment. For example,
|
|
10
|
-
* if the service is running in a Spin environment, the attribute "rejectUnauthorized" is
|
|
11
|
-
* set to false
|
|
12
|
-
*/
|
|
13
|
-
export async function httpsAgent() {
|
|
14
|
-
return new https.Agent({ rejectUnauthorized: await shouldRejectUnauthorizedRequests() });
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Spin stores the CA certificate in the keychain and it should be used when sending HTTP
|
|
18
|
-
* requests to Spin instances. However, Node doesn't read certificates from the Keychain
|
|
19
|
-
* by default, which leads to Shopifolks running into issues that they workaround by setting the
|
|
20
|
-
* NODE_TLS_REJECT_UNAUTHORIZED=0 environment variable, which applies to all the HTTP
|
|
21
|
-
* requests sent from the CLI (context: https://github.com/nodejs/node/issues/39657)
|
|
22
|
-
* This utility function allows controlling the behavior in a per-service level by returning
|
|
23
|
-
* the value of for the "rejectUnauthorized" attribute that's used in the https agent.
|
|
24
|
-
*
|
|
25
|
-
* @returns A promise that resolves with a boolean indicating whether
|
|
26
|
-
* unauthorized requests should be rejected or not.
|
|
27
|
-
*/
|
|
28
|
-
export async function shouldRejectUnauthorizedRequests() {
|
|
29
|
-
return (await serviceEnvironment()) !== Environment.Spin;
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=http.js.map
|
package/dist/http.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,kBAAkB,EAAC,MAAM,uCAAuC,CAAA;AACrF,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAC,OAAO,IAAI,KAAK,EAAC,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAC,OAAO,IAAI,QAAQ,EAAC,MAAM,oBAAoB,CAAA;AAEtD,OAAO,EACL,SAAS,EACT,YAAY,EAIZ,WAAW,EACX,IAAI,EACJ,SAAS,EACT,YAAY,EACZ,OAAO,GACR,MAAM,IAAI,CAAA;AAEX;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU;IAC9B,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,EAAC,kBAAkB,EAAE,MAAM,gCAAgC,EAAE,EAAC,CAAC,CAAA;AACxF,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,gCAAgC;IACpD,OAAO,CAAC,MAAM,kBAAkB,EAAE,CAAC,KAAK,WAAW,CAAC,IAAI,CAAA;AAC1D,CAAC","sourcesContent":["import {Environment, serviceEnvironment} from './private/node/environment/service.js'\nimport https from 'https'\n\nexport {default as fetch} from './http/fetch.js'\nexport {shopifyFetch} from './http/fetch.js'\nexport {default as formData} from './http/formdata.js'\n\nexport {\n createApp,\n createRouter,\n IncomingMessage,\n ServerResponse,\n CompatibilityEvent,\n createError,\n send,\n sendError,\n sendRedirect,\n H3Error,\n} from 'h3'\n\n/**\n * This utility function returns the https.Agent to use for a given service. The agent\n * includes the right configuration based on the service's environment. For example,\n * if the service is running in a Spin environment, the attribute \"rejectUnauthorized\" is\n * set to false\n */\nexport async function httpsAgent() {\n return new https.Agent({rejectUnauthorized: await shouldRejectUnauthorizedRequests()})\n}\n\n/**\n * Spin stores the CA certificate in the keychain and it should be used when sending HTTP\n * requests to Spin instances. However, Node doesn't read certificates from the Keychain\n * by default, which leads to Shopifolks running into issues that they workaround by setting the\n * NODE_TLS_REJECT_UNAUTHORIZED=0 environment variable, which applies to all the HTTP\n * requests sent from the CLI (context: https://github.com/nodejs/node/issues/39657)\n * This utility function allows controlling the behavior in a per-service level by returning\n * the value of for the \"rejectUnauthorized\" attribute that's used in the https agent.\n *\n * @returns A promise that resolves with a boolean indicating whether\n * unauthorized requests should be rejected or not.\n */\nexport async function shouldRejectUnauthorizedRequests(): Promise<boolean> {\n return (await serviceEnvironment()) !== Environment.Spin\n}\n"]}
|
package/dist/npm.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
interface JSON {
|
|
2
|
-
[key: string]: JSONValue;
|
|
3
|
-
}
|
|
4
|
-
declare type JSONValue = string | number | boolean | JSON | JSONValue[];
|
|
5
|
-
export interface PackageJSON extends JSON {
|
|
6
|
-
name: string;
|
|
7
|
-
author: string;
|
|
8
|
-
dependencies: {
|
|
9
|
-
[key: string]: string;
|
|
10
|
-
};
|
|
11
|
-
devDependencies: {
|
|
12
|
-
[key: string]: string;
|
|
13
|
-
};
|
|
14
|
-
resolutions: {
|
|
15
|
-
[key: string]: string;
|
|
16
|
-
};
|
|
17
|
-
overrides: {
|
|
18
|
-
[key: string]: string;
|
|
19
|
-
};
|
|
20
|
-
scripts: {
|
|
21
|
-
[key: string]: string;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
export declare function readPackageJSON(directory: string): Promise<PackageJSON>;
|
|
25
|
-
export declare function writePackageJSON(directory: string, packageJSON: JSON): Promise<void>;
|
|
26
|
-
export declare function updateAppData(packageJSON: JSON, name: string): Promise<void>;
|
|
27
|
-
export {};
|
package/dist/npm.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { join } from './path.js';
|
|
2
|
-
import * as file from './file.js';
|
|
3
|
-
import * as os from './public/node/os.js';
|
|
4
|
-
import { debug, token, content } from './output.js';
|
|
5
|
-
export async function readPackageJSON(directory) {
|
|
6
|
-
debug(content `Reading and decoding the content from package.json at ${token.path(directory)}...`);
|
|
7
|
-
const packagePath = join(directory, 'package.json');
|
|
8
|
-
const packageJSON = JSON.parse(await file.read(packagePath));
|
|
9
|
-
return packageJSON;
|
|
10
|
-
}
|
|
11
|
-
export async function writePackageJSON(directory, packageJSON) {
|
|
12
|
-
debug(content `JSON-encoding and writing content to package.json at ${token.path(directory)}...`);
|
|
13
|
-
const packagePath = join(directory, 'package.json');
|
|
14
|
-
await file.write(packagePath, JSON.stringify(packageJSON, null, 2));
|
|
15
|
-
}
|
|
16
|
-
export async function updateAppData(packageJSON, name) {
|
|
17
|
-
packageJSON.name = name;
|
|
18
|
-
packageJSON.author = (await os.username()) ?? '';
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=npm.js.map
|
package/dist/npm.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"npm.js","sourceRoot":"","sources":["../src/npm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,EAAE,MAAM,qBAAqB,CAAA;AACzC,OAAO,EAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAC,MAAM,aAAa,CAAA;AAkBjD,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,SAAiB;IACrD,KAAK,CAAC,OAAO,CAAA,yDAAyD,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;IACjG,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAA;IACnD,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAA;IAE5D,OAAO,WAAW,CAAA;AACpB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,SAAiB,EAAE,WAAiB;IACzE,KAAK,CAAC,OAAO,CAAA,wDAAwD,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;IAChG,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAA;IACnD,MAAM,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;AACrE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,WAAiB,EAAE,IAAY;IACjE,WAAW,CAAC,IAAI,GAAG,IAAI,CAAA;IACvB,WAAW,CAAC,MAAM,GAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAA;AAClD,CAAC","sourcesContent":["import {join} from './path.js'\nimport * as file from './file.js'\nimport * as os from './public/node/os.js'\nimport {debug, token, content} from './output.js'\n\ninterface JSON {\n [key: string]: JSONValue\n}\n\ntype JSONValue = string | number | boolean | JSON | JSONValue[]\n\nexport interface PackageJSON extends JSON {\n name: string\n author: string\n dependencies: {[key: string]: string}\n devDependencies: {[key: string]: string}\n resolutions: {[key: string]: string}\n overrides: {[key: string]: string}\n scripts: {[key: string]: string}\n}\n\nexport async function readPackageJSON(directory: string): Promise<PackageJSON> {\n debug(content`Reading and decoding the content from package.json at ${token.path(directory)}...`)\n const packagePath = join(directory, 'package.json')\n const packageJSON = JSON.parse(await file.read(packagePath))\n\n return packageJSON\n}\n\nexport async function writePackageJSON(directory: string, packageJSON: JSON): Promise<void> {\n debug(content`JSON-encoding and writing content to package.json at ${token.path(directory)}...`)\n const packagePath = join(directory, 'package.json')\n await file.write(packagePath, JSON.stringify(packageJSON, null, 2))\n}\n\nexport async function updateAppData(packageJSON: JSON, name: string): Promise<void> {\n packageJSON.name = name\n packageJSON.author = (await os.username()) ?? ''\n}\n"]}
|
package/dist/path.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { OverloadParameters } from './typing/overloaded-parameters.js';
|
|
3
|
-
import { relative, dirname, join, normalize, resolve, basename, extname, isAbsolute, parse } from 'pathe';
|
|
4
|
-
import { findUp as internalFindUp } from 'find-up';
|
|
5
|
-
import type { URL } from 'url';
|
|
6
|
-
import type { Pattern, Options } from 'fast-glob';
|
|
7
|
-
export { join, relative, dirname, normalize, resolve, basename, extname, isAbsolute, parse };
|
|
8
|
-
export declare function glob(pattern: Pattern | Pattern[], options?: Options): Promise<string[]>;
|
|
9
|
-
export { pathToFileURL } from 'url';
|
|
10
|
-
export declare function findUp(matcher: OverloadParameters<typeof internalFindUp>[0], options: OverloadParameters<typeof internalFindUp>[1]): ReturnType<typeof internalFindUp>;
|
|
11
|
-
/**
|
|
12
|
-
* Given an absolute filesystem path, it makes it relative to
|
|
13
|
-
* the current working directory. This is useful when logging paths
|
|
14
|
-
* to allow the users to click on the file and let the OS open it
|
|
15
|
-
* in the editor of choice.
|
|
16
|
-
* @param path - Path to relativize
|
|
17
|
-
* @returns Relativized path.
|
|
18
|
-
*/
|
|
19
|
-
export declare function relativize(path: string, cwd?: string): string;
|
|
20
|
-
/**
|
|
21
|
-
* Given a module's import.meta.url it returns the directory containing the module.
|
|
22
|
-
* @param moduleURL - The value of import.meta.url in the context of the caller module.
|
|
23
|
-
* @returns The path to the directory containing the caller module.
|
|
24
|
-
*/
|
|
25
|
-
export declare function moduleDirectory(moduleURL: string | URL): string;
|
package/dist/path.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"path.js","sourceRoot":"","sources":["../src/path.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,WAAW,CAAA;AACjC,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAC,MAAM,OAAO,CAAA;AACvG,OAAO,EAAC,MAAM,IAAI,cAAc,EAAC,MAAM,SAAS,CAAA;AAChD,OAAO,EAAC,aAAa,EAAC,MAAM,KAAK,CAAA;AAKjC,OAAO,EAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,E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,IAAI,kBAAkB,GAAG,CAAC,EAAE;QACnE,OAAO,IAAI,CAAA;KACZ;SAAM;QACL,OAAO,YAAY,CAAA;KACpB;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,SAAuB;IACrD,OAAO,OAAO,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAA;AAC1C,CAAC","sourcesContent":["import {OverloadParameters} from './typing/overloaded-parameters.js'\nimport commondir from 'commondir'\nimport {relative, dirname, join, normalize, resolve, basename, extname, isAbsolute, parse} from 'pathe'\nimport {findUp as internalFindUp} from 'find-up'\nimport {fileURLToPath} from 'url'\n// eslint-disable-next-line node/prefer-global/url\nimport type {URL} from 'url'\nimport type {Pattern, Options} from 'fast-glob'\n\nexport {join, relative, dirname, normalize, resolve, basename, extname, isAbsolute, parse}\n\nexport async function glob(pattern: Pattern | Pattern[], options?: Options): Promise<string[]> {\n const {default: fastGlob} = await import('fast-glob')\n let overridenOptions = options\n if (options?.dot == null) {\n overridenOptions = {...options, dot: true}\n }\n return fastGlob(pattern, overridenOptions)\n}\nexport {pathToFileURL} from 'url'\n\nexport async function findUp(\n matcher: OverloadParameters<typeof internalFindUp>[0],\n options: OverloadParameters<typeof internalFindUp>[1],\n): ReturnType<typeof internalFindUp> {\n // findUp has odd typing\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const got = await internalFindUp(matcher as any, options)\n return got ? normalize(got) : undefined\n}\n\n/**\n * Given an absolute filesystem path, it makes it relative to\n * the current working directory. This is useful when logging paths\n * to allow the users to click on the file and let the OS open it\n * in the editor of choice.\n * @param path - Path to relativize\n * @returns Relativized path.\n */\nexport function relativize(path: string, cwd: string = process.cwd()): string {\n const result = commondir([path, cwd])\n const relativePath = relative(cwd, path)\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const relativeComponents = relativePath.split('/').filter((component) => component === '..').length\n if (result === '/' || relativePath === '' || relativeComponents > 2) {\n return path\n } else {\n return relativePath\n }\n}\n\n/**\n * Given a module's import.meta.url it returns the directory containing the module.\n * @param moduleURL - The value of import.meta.url in the context of the caller module.\n * @returns The path to the directory containing the caller module.\n */\nexport function moduleDirectory(moduleURL: string | URL): string {\n return dirname(fileURLToPath(moduleURL))\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Table.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/Table.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAC9B,OAAO,EAAC,UAAU,EAAC,MAAM,qCAAqC,CAAA;AAC9D,OAAO,EAAC,GAAG,EAAE,IAAI,EAAC,MAAM,KAAK,CAAA;AAC7B,OAAO,KAAK,MAAM,OAAO,CAAA;AAQzB,MAAM,KAAK,GAAoB,CAAC,EAAC,KAAK,EAAC,EAAE,EAAE;IACzC,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAClC,MAAM,iBAAiB,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAA;IAE7E,OAAO,CACL,oBAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,EAAC,QAAQ,EAAE,CAAC,IACpC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,CAC9B,oBAAC,GAAG,IAAC,GAAG,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,KAAK,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACjE,oBAAC,GAAG,IAAC,KAAK,EAAE,iBAAiB,GAAG,CAAC;YAC/B,oBAAC,IAAI;gBAAE,UAAU,CAAC,MAAM,CAAC;oBAAS,CAC9B;QACN,oBAAC,GAAG,IAAC,QAAQ,EAAE,CAAC;YACd,oBAAC,IAAI,IAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAE,GAAI,CAC3B,CACF,CACP,CAAC,CACE,CACP,CAAA;AACH,CAAC,CAAA;AAED,eAAe,KAAK,CAAA","sourcesContent":["import {List} from './List.js'\nimport {capitalize} from '../../../../public/common/string.js'\nimport {Box, Text} from 'ink'\nimport React from 'react'\n\nexport interface Props {\n table: {\n [header: string]: string[]\n }\n}\n\nconst Table: React.FC<Props> = ({table}) => {\n const headers = Object.keys(table)\n const headerColumnWidth = Math.max(...headers.map((header) => header.length))\n\n return (\n <Box flexDirection=\"column\" paddingY={1}>\n {headers.map((header, index) => (\n <Box key={index} marginBottom={index === headers.length - 1 ? 0 : 1}>\n <Box width={headerColumnWidth + 1}>\n <Text>{capitalize(header)}:</Text>\n </Box>\n <Box flexGrow={1}>\n <List items={table[header]!} />\n </Box>\n </Box>\n ))}\n </Box>\n )\n}\n\nexport default Table\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deep-required.js","sourceRoot":"","sources":["../../src/typing/deep-required.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Converts a mapping type to be non-optional\n *\n * ```\n * type T = DeepRequired<{optionalKey?: string, nullableValue: string | null, undefinableValue: string | undefined}>\n * T = {optionalKey: string, nullableValue: string, undefinableValue: string}\n * ```\n *\n */\nexport type DeepRequired<T> = {\n [TKey in keyof Required<T>]: NonNullable<Required<T>[TKey]>\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"overloaded-parameters.js","sourceRoot":"","sources":["../../src/typing/overloaded-parameters.ts"],"names":[],"mappings":"","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\ntype OverloadProps<TOverload> = Pick<TOverload, keyof TOverload>\n\n// Prevent infinite recursion by stopping recursion when TPartialOverload\n// has accumulated all of the TOverload signatures.\ntype OverloadUnionRecursive<TOverload, TPartialOverload = unknown> = TOverload extends (\n ...args: infer TArgs\n) => infer TReturn\n ? TPartialOverload extends TOverload\n ? never\n :\n | OverloadUnionRecursive<\n TPartialOverload & TOverload,\n TPartialOverload & ((...args: TArgs) => TReturn) & OverloadProps<TOverload>\n >\n | ((...args: TArgs) => TReturn)\n : never\n\n// The \"() => never\" signature must be hoisted to the \"front\" of the\n// intersection, for two reasons: a) because recursion stops when it is\n// encountered, and b) it seems to prevent the collapse of subsequent\n// \"compatible\" signatures (eg. \"() => void\" into \"(a?: 1) => void\"),\n// which gives a direct conversion to a union.\ntype OverloadUnion<TOverload extends (...args: any[]) => any> = Exclude<\n OverloadUnionRecursive<(() => never) & TOverload>,\n TOverload extends () => never ? never : () => never\n>\n\n// Inferring a union of parameter tuples or return types is now possible.\nexport type OverloadParameters<T extends (...args: any[]) => any> = Parameters<OverloadUnion<T>>\nexport type OverloadReturnType<T extends (...args: any[]) => any> = ReturnType<OverloadUnion<T>>\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pick-by-prefix.js","sourceRoot":"","sources":["../../src/typing/pick-by-prefix.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Produces a subset of a mapping type, where the keys either match some prefix string, or are in a list of exact matches\n *\n * ```\n * type T = PickByPrefix<{foo_1: number, foo_2: number, nope: string, included: string, also: number}, 'foo_', 'included' | 'also'>\n *\n * T = {foo_1: number, foo_2: number, included: string, also: number}\n * ```\n */\nexport type PickByPrefix<TMapping, TPrefix extends string, TKeys extends keyof TMapping = never> = {\n [TKey in keyof TMapping as TKey extends `${TPrefix}${infer _TSuffix}` | TKeys ? TKey : never]: TMapping[TKey]\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"simple-definitions.js","sourceRoot":"","sources":["../../src/typing/simple-definitions.ts"],"names":[],"mappings":"","sourcesContent":["declare module 'color-json' {\n function colour(content: string | object): string\n export default colour\n}\n"]}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import AutocompletePrompt from 'inquirer-autocomplete-prompt';
|
|
3
|
-
import { Question, Answers } from 'inquirer';
|
|
4
|
-
import { Interface } from 'readline';
|
|
5
|
-
export declare class CustomAutocomplete extends AutocompletePrompt {
|
|
6
|
-
protected isAutocomplete: boolean;
|
|
7
|
-
constructor(questions: Question<Answers>, rl: Interface, answers: Answers);
|
|
8
|
-
protected render(error?: string): void;
|
|
9
|
-
protected getQuestion(): string;
|
|
10
|
-
protected prefix(): string;
|
|
11
|
-
}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import colors from '../../public/node/colors.js';
|
|
2
|
-
import { escapeRegExp } from '../../public/common/string.js';
|
|
3
|
-
import AutocompletePrompt from 'inquirer-autocomplete-prompt';
|
|
4
|
-
import Paginator from 'inquirer/lib/utils/paginator.js';
|
|
5
|
-
export class CustomAutocomplete extends AutocompletePrompt {
|
|
6
|
-
constructor(questions, rl, answers) {
|
|
7
|
-
super(questions, rl, answers);
|
|
8
|
-
this.isAutocomplete = true;
|
|
9
|
-
this.paginator = new Paginator(this.screen, {
|
|
10
|
-
isInfinite: false,
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
render(error) {
|
|
14
|
-
let content = this.getQuestion();
|
|
15
|
-
let bottomContent = '';
|
|
16
|
-
if (this.status !== 'answered') {
|
|
17
|
-
content += colors.gray(this.isAutocomplete && this.firstRender ? 'Type to search… ' : '… ');
|
|
18
|
-
}
|
|
19
|
-
if (this.status === 'answered') {
|
|
20
|
-
content += `${colors.dim('·')} ${colors.magenta(this.shortAnswer || this.answerName || this.answer)}`;
|
|
21
|
-
process.stdout.write('\u001b[?25h');
|
|
22
|
-
}
|
|
23
|
-
else if (this.searching) {
|
|
24
|
-
content += this.rl.line;
|
|
25
|
-
bottomContent += ` ${colors.magenta.dim('Searching...')}`;
|
|
26
|
-
}
|
|
27
|
-
else if (this.nbChoices) {
|
|
28
|
-
const choicesStr = listRender(this.currentChoices, this.selected, this.isAutocomplete ? this.rl.line : undefined);
|
|
29
|
-
content += this.isAutocomplete ? this.rl.line : '';
|
|
30
|
-
const indexPosition = this.selected;
|
|
31
|
-
let realIndexPosition = 0;
|
|
32
|
-
this.currentChoices.choices.every((choice, index) => {
|
|
33
|
-
if (index > indexPosition) {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
if (choice.type === 'separator') {
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
const name = choice.name;
|
|
40
|
-
realIndexPosition += name ? name.split('\n').length : 0;
|
|
41
|
-
return true;
|
|
42
|
-
});
|
|
43
|
-
bottomContent += this.paginator.paginate(choicesStr, realIndexPosition, this.isAutocomplete ? 10 : 500);
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
content += this.rl.line;
|
|
47
|
-
bottomContent += ` ${colors.magenta('No matching choices')}`;
|
|
48
|
-
}
|
|
49
|
-
if (error) {
|
|
50
|
-
bottomContent += `\n${colors.magenta('>> ')}${error}`;
|
|
51
|
-
}
|
|
52
|
-
this.firstRender = false;
|
|
53
|
-
this.screen.render(content, bottomContent);
|
|
54
|
-
}
|
|
55
|
-
getQuestion() {
|
|
56
|
-
return `${this.prefix()} ${colors.bold(this.opt.message)}${this.opt.suffix}${colors.reset(' ')}`;
|
|
57
|
-
}
|
|
58
|
-
prefix() {
|
|
59
|
-
const color = colors.magenta.bold;
|
|
60
|
-
return this.status === 'answered' ? color('✔') : color('?');
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
function listRender(choices, pointer, searchToken) {
|
|
64
|
-
let output = '';
|
|
65
|
-
let separatorOffset = 0;
|
|
66
|
-
choices.forEach((choice, i) => {
|
|
67
|
-
if (choice.type === 'separator') {
|
|
68
|
-
separatorOffset++;
|
|
69
|
-
if (choice.line.includes('──────────────')) {
|
|
70
|
-
output += `\n`;
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
output += ` ${colors.dim.underline(choice)}\n`;
|
|
74
|
-
}
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
if (choice.disabled) {
|
|
78
|
-
separatorOffset++;
|
|
79
|
-
output += ` - ${choice.name}`;
|
|
80
|
-
output += ` (${typeof choice.disabled === 'string' ? choice.disabled : 'Disabled'})`;
|
|
81
|
-
output += '\n';
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
const isSelected = i - separatorOffset === pointer;
|
|
85
|
-
let line = (isSelected ? '> ' : ' ') + choice.name;
|
|
86
|
-
if (isSelected) {
|
|
87
|
-
line = colors.magenta(line);
|
|
88
|
-
}
|
|
89
|
-
if (searchToken) {
|
|
90
|
-
const regexified = escapeRegExp(searchToken);
|
|
91
|
-
line = line
|
|
92
|
-
.split(new RegExp(`(${regexified})`, 'ig'))
|
|
93
|
-
.map((token) => {
|
|
94
|
-
if (token.match(new RegExp(regexified, 'ig'))) {
|
|
95
|
-
return colors.magenta.dim(token);
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
return isSelected ? colors.magenta(token) : token;
|
|
99
|
-
}
|
|
100
|
-
})
|
|
101
|
-
.join('');
|
|
102
|
-
}
|
|
103
|
-
else if (isSelected) {
|
|
104
|
-
line = colors.magenta(line);
|
|
105
|
-
}
|
|
106
|
-
output += `${line} \n`;
|
|
107
|
-
});
|
|
108
|
-
return output.replace(/\n$/, '');
|
|
109
|
-
}
|
|
110
|
-
//# sourceMappingURL=autocomplete.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"autocomplete.js","sourceRoot":"","sources":["../../../src/ui/inquirer/autocomplete.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,6BAA6B,CAAA;AAChD,OAAO,EAAC,YAAY,EAAC,MAAM,+BAA+B,CAAA;AAC1D,OAAO,kBAAkB,MAAM,8BAA8B,CAAA;AAI7D,OAAO,SAAS,MAAM,iCAAiC,CAAA;AAGvD,MAAM,OAAO,kBAAmB,SAAQ,kBAAkB;IAGxD,YAAY,SAA4B,EAAE,EAAa,EAAE,OAAg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U,GAAG,CAAC,GAAG,eAAe,KAAK,OAAO,CAAA;QAClD,IAAI,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,IAAI,CAAA;QAEnD,IAAI,UAAU,EAAE;YACd,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;SAC5B;QAED,IAAI,WAAW,EAAE;YACf,MAAM,UAAU,GAAG,YAAY,CAAC,WAAW,CAAC,CAAA;YAC5C,IAAI,GAAG,IAAI;iBACR,KAAK,CAAC,IAAI,MAAM,CAAC,IAAI,UAAU,GAAG,EAAE,IAAI,CAAC,CAAC;iBAC1C,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;gBACb,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,EAAE;oBAC7C,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;iBACjC;qBAAM;oBACL,OAAO,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;iBAClD;YACH,CAAC,CAAC;iBACD,IAAI,CAAC,EAAE,CAAC,CAAA;SACZ;aAAM,IAAI,UAAU,EAAE;YACrB,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;SAC5B;QAED,MAAM,IAAI,GAAG,IAAI,KAAK,CAAA;IACxB,CAAC,CAAC,CAAA;IAEF,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;AAClC,CAAC","sourcesContent":["import colors from '../../public/node/colors.js'\nimport {escapeRegExp} from '../../public/common/string.js'\nimport AutocompletePrompt from 'inquirer-autocomplete-prompt'\nimport DistinctChoice from 'inquirer/lib/objects/choices'\nimport {Question, Answers} from 'inquirer'\n\nimport Paginator from 'inquirer/lib/utils/paginator.js'\nimport {Interface} from 'readline'\n\nexport class CustomAutocomplete extends AutocompletePrompt {\n protected isAutocomplete: boolean\n\n constructor(questions: Question<Answers>, rl: Interface, answers: Answers) {\n super(questions, rl, answers)\n this.isAutocomplete = true\n this.paginator = new Paginator(this.screen, {\n isInfinite: false,\n })\n }\n\n protected render(error?: string) {\n let content = this.getQuestion()\n let bottomContent = ''\n\n if (this.status !== 'answered') {\n content += colors.gray(this.isAutocomplete && this.firstRender ? 'Type to search… ' : '… ')\n }\n\n if (this.status === 'answered') {\n content += `${colors.dim('·')} ${colors.magenta(this.shortAnswer || this.answerName || this.answer)}`\n process.stdout.write('\\u001b[?25h')\n } else if (this.searching) {\n content += this.rl.line\n bottomContent += ` ${colors.magenta.dim('Searching...')}`\n } else if (this.nbChoices) {\n const choicesStr = listRender(this.currentChoices, this.selected, this.isAutocomplete ? this.rl.line : undefined)\n content += this.isAutocomplete ? this.rl.line : ''\n const indexPosition = this.selected\n let realIndexPosition = 0\n this.currentChoices.choices.every((choice, index: number) => {\n if (index > indexPosition) {\n return false\n }\n if (choice.type === 'separator') {\n return true\n }\n const name = choice.name\n realIndexPosition += name ? name.split('\\n').length : 0\n return true\n })\n bottomContent += this.paginator.paginate(choicesStr, realIndexPosition, this.isAutocomplete ? 10 : 500)\n } else {\n content += this.rl.line\n bottomContent += ` ${colors.magenta('No matching choices')}`\n }\n\n if (error) {\n bottomContent += `\\n${colors.magenta('>> ')}${error}`\n }\n\n this.firstRender = false\n\n this.screen.render(content, bottomContent)\n }\n\n protected getQuestion(): string {\n return `${this.prefix()} ${colors.bold(this.opt.message)}${this.opt.suffix}${colors.reset(' ')}`\n }\n\n protected prefix(): string {\n const color = colors.magenta.bold\n return this.status === 'answered' ? color('✔') : color('?')\n }\n}\n\nfunction listRender(choices: DistinctChoice, pointer: number, searchToken?: string): string {\n let output = ''\n let separatorOffset = 0\n\n choices.forEach((choice, i: number) => {\n if (choice.type === 'separator') {\n separatorOffset++\n if (choice.line.includes('──────────────')) {\n output += `\\n`\n } else {\n output += ` ${colors.dim.underline(choice)}\\n`\n }\n return\n }\n\n if (choice.disabled) {\n separatorOffset++\n output += ` - ${choice.name}`\n output += ` (${typeof choice.disabled === 'string' ? choice.disabled : 'Disabled'})`\n output += '\\n'\n return\n }\n\n const isSelected = i - separatorOffset === pointer\n let line = (isSelected ? '> ' : ' ') + choice.name\n\n if (isSelected) {\n line = colors.magenta(line)\n }\n\n if (searchToken) {\n const regexified = escapeRegExp(searchToken)\n line = line\n .split(new RegExp(`(${regexified})`, 'ig'))\n .map((token) => {\n if (token.match(new RegExp(regexified, 'ig'))) {\n return colors.magenta.dim(token)\n } else {\n return isSelected ? colors.magenta(token) : token\n }\n })\n .join('')\n } else if (isSelected) {\n line = colors.magenta(line)\n }\n\n output += `${line} \\n`\n })\n\n return output.replace(/\\n$/, '')\n}\n"]}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import Input from 'inquirer/lib/prompts/input.js';
|
|
3
|
-
import { Question, Answers } from 'inquirer';
|
|
4
|
-
import { Interface } from 'readline';
|
|
5
|
-
export declare class CustomInput extends Input {
|
|
6
|
-
protected isPassword: boolean;
|
|
7
|
-
constructor(questions: Question<Answers>, rl: Interface, answers: Answers);
|
|
8
|
-
protected render(error?: string): void;
|
|
9
|
-
protected getQuestion(): string;
|
|
10
|
-
protected prefix(): string;
|
|
11
|
-
protected onError(data: {
|
|
12
|
-
isValid: string;
|
|
13
|
-
value: string;
|
|
14
|
-
}): void;
|
|
15
|
-
private formatContent;
|
|
16
|
-
}
|