@shopify/cli-kit 3.32.0 → 3.32.1
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/api.d.ts +2 -5
- package/dist/api.js +2 -5
- package/dist/api.js.map +1 -1
- package/dist/http/fetch.js +1 -1
- package/dist/http/fetch.js.map +1 -1
- package/dist/http.d.ts +0 -1
- package/dist/http.js +0 -1
- package/dist/http.js.map +1 -1
- package/dist/index.d.ts +0 -5
- package/dist/index.js +0 -5
- package/dist/index.js.map +1 -1
- package/dist/npm.js +1 -1
- package/dist/npm.js.map +1 -1
- package/dist/private/node/analytics.js +2 -2
- package/dist/private/node/analytics.js.map +1 -1
- package/dist/private/node/api/graphql.d.ts +5 -0
- package/dist/private/node/api/graphql.js +63 -0
- package/dist/private/node/api/graphql.js.map +1 -0
- package/dist/{api/common.d.ts → private/node/api/headers.d.ts} +3 -8
- package/dist/{api/common.js → private/node/api/headers.js} +20 -60
- package/dist/private/node/api/headers.js.map +1 -0
- package/dist/private/node/ui/components/FullScreen.js +11 -9
- package/dist/private/node/ui/components/FullScreen.js.map +1 -1
- package/dist/private/node/ui/components/SelectPrompt.js +15 -3
- package/dist/private/node/ui/components/SelectPrompt.js.map +1 -1
- package/dist/private/node/ui/components/Table.js +1 -1
- package/dist/private/node/ui/components/Table.js.map +1 -1
- package/dist/public/common/collection.js.map +1 -1
- package/dist/public/common/object.js +3 -3
- package/dist/public/common/object.js.map +1 -1
- package/dist/public/common/string.d.ts +55 -1
- package/dist/public/common/string.js +93 -1
- package/dist/public/common/string.js.map +1 -1
- package/dist/public/node/api/admin.d.ts +11 -0
- package/dist/public/node/api/admin.js +70 -0
- package/dist/public/node/api/admin.js.map +1 -0
- package/dist/public/node/api/oxygen.d.ts +22 -0
- package/dist/public/node/api/oxygen.js +40 -0
- package/dist/public/node/api/oxygen.js.map +1 -0
- package/dist/{api → public/node/api}/partners.d.ts +11 -3
- package/dist/public/node/api/partners.js +40 -0
- package/dist/public/node/api/partners.js.map +1 -0
- package/dist/public/node/base-command.js +1 -1
- package/dist/public/node/base-command.js.map +1 -1
- package/dist/public/node/crypto.d.ts +42 -0
- package/dist/public/node/crypto.js +55 -0
- package/dist/public/node/crypto.js.map +1 -0
- package/dist/{template.d.ts → public/node/liquid.d.ts} +10 -2
- package/dist/{template.js → public/node/liquid.js} +18 -13
- package/dist/public/node/liquid.js.map +1 -0
- package/dist/public/node/os.d.ts +16 -0
- package/dist/{os.js → public/node/os.js} +33 -28
- package/dist/public/node/os.js.map +1 -0
- package/dist/public/node/presets.js +2 -2
- package/dist/public/node/presets.js.map +1 -1
- package/dist/public/node/ruby.d.ts +11 -7
- package/dist/public/node/ruby.js +89 -21
- package/dist/public/node/ruby.js.map +1 -1
- package/dist/public/node/tcp.d.ts +2 -0
- package/dist/public/node/tcp.js +9 -0
- package/dist/public/node/tcp.js.map +1 -1
- package/dist/public/node/toml.d.ts +15 -0
- package/dist/public/node/toml.js +20 -0
- package/dist/public/node/toml.js.map +1 -0
- package/dist/public/node/vscode.d.ts +14 -0
- package/dist/{vscode.js → public/node/vscode.js} +13 -7
- package/dist/public/node/vscode.js.map +1 -0
- package/dist/session/authorize.d.ts +4 -0
- package/dist/session/authorize.js +7 -2
- package/dist/session/authorize.js.map +1 -1
- package/dist/{api/identity.d.ts → session/identity-token-validation.d.ts} +0 -0
- package/dist/{api/identity.js → session/identity-token-validation.js} +1 -1
- package/dist/session/identity-token-validation.js.map +1 -0
- package/dist/session/schema.d.ts +18 -18
- package/dist/session/store.js +1 -1
- package/dist/session/store.js.map +1 -1
- package/dist/session.js +3 -3
- package/dist/session.js.map +1 -1
- package/dist/system.js +1 -1
- package/dist/system.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/ui/inquirer/autocomplete.js +1 -1
- package/dist/ui/inquirer/autocomplete.js.map +1 -1
- package/package.json +2 -1
- package/dist/api/admin.d.ts +0 -3
- package/dist/api/admin.js +0 -56
- package/dist/api/admin.js.map +0 -1
- package/dist/api/common.js.map +0 -1
- package/dist/api/identity.js.map +0 -1
- package/dist/api/oxygen.d.ts +0 -5
- package/dist/api/oxygen.js +0 -30
- package/dist/api/oxygen.js.map +0 -1
- package/dist/api/partners.js +0 -44
- package/dist/api/partners.js.map +0 -1
- package/dist/http/graphql.d.ts +0 -13
- package/dist/http/graphql.js +0 -12
- package/dist/http/graphql.js.map +0 -1
- package/dist/os.d.ts +0 -11
- package/dist/os.js.map +0 -1
- package/dist/string.d.ts +0 -28
- package/dist/string.js +0 -77
- package/dist/string.js.map +0 -1
- package/dist/template.js.map +0 -1
- package/dist/toml.d.ts +0 -3
- package/dist/toml.js +0 -8
- package/dist/toml.js.map +0 -1
- package/dist/vscode.d.ts +0 -8
- package/dist/vscode.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import colors from '../../public/node/colors.js';
|
|
2
|
-
import { escapeRegExp } from '../../string.js';
|
|
2
|
+
import { escapeRegExp } from '../../public/common/string.js';
|
|
3
3
|
import AutocompletePrompt from 'inquirer-autocomplete-prompt';
|
|
4
4
|
import Paginator from 'inquirer/lib/utils/paginator.js';
|
|
5
5
|
export class CustomAutocomplete extends AutocompletePrompt {
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,SA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F,MAAM,IAAI,IAAI,CAAA;YACd,OAAM;SACP;QAED,MAAM,UAAU,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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopify/cli-kit",
|
|
3
|
-
"version": "3.32.
|
|
3
|
+
"version": "3.32.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A set of utilities, interfaces, and models that are common across all the platform features",
|
|
6
6
|
"keywords": [
|
|
@@ -77,6 +77,7 @@
|
|
|
77
77
|
"@oclif/core": "1.21.0",
|
|
78
78
|
"@types/archiver": "5.3.1",
|
|
79
79
|
"abort-controller": "3.0.0",
|
|
80
|
+
"ansi-escapes": "6.0.0",
|
|
80
81
|
"archiver": "5.3.1",
|
|
81
82
|
"chalk": "5.1.0",
|
|
82
83
|
"change-case": "4.1.2",
|
package/dist/api/admin.d.ts
DELETED
package/dist/api/admin.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { buildHeaders, debugLogRequest, handlingErrors } from './common.js';
|
|
2
|
-
import { debug, content, token as outputToken } from '../output.js';
|
|
3
|
-
import { Bug, Abort } from '../error.js';
|
|
4
|
-
import { graphqlClient } from '../http/graphql.js';
|
|
5
|
-
import { gql } from 'graphql-request';
|
|
6
|
-
export async function request(query, session, variables) {
|
|
7
|
-
const api = 'Admin';
|
|
8
|
-
return handlingErrors(api, async () => {
|
|
9
|
-
const version = await fetchApiVersion(session);
|
|
10
|
-
const url = adminUrl(session.storeFqdn, version);
|
|
11
|
-
const headers = await buildHeaders(session.token);
|
|
12
|
-
const client = await graphqlClient({ headers, url });
|
|
13
|
-
debugLogRequest(api, query, variables, headers);
|
|
14
|
-
const response = await client.request(query, variables);
|
|
15
|
-
return response;
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
async function fetchApiVersion(session) {
|
|
19
|
-
const url = adminUrl(session.storeFqdn, 'unstable');
|
|
20
|
-
const query = apiVersionQuery();
|
|
21
|
-
const headers = await buildHeaders(session.token);
|
|
22
|
-
const client = await graphqlClient({ url, headers });
|
|
23
|
-
debug(`
|
|
24
|
-
Sending Admin GraphQL request to URL ${url} with query:
|
|
25
|
-
${query}
|
|
26
|
-
`);
|
|
27
|
-
const data = await client
|
|
28
|
-
.request(query, {})
|
|
29
|
-
.catch((err) => {
|
|
30
|
-
if (err.response.status === 403) {
|
|
31
|
-
const storeName = session.storeFqdn.replace('.myshopify.com', '');
|
|
32
|
-
throw new Abort(content `Looks like you don't have access this dev store: (${outputToken.link(storeName, `https://${session.storeFqdn}`)})`, content `If you're not the owner, create a dev store staff account for yourself`);
|
|
33
|
-
}
|
|
34
|
-
throw new Bug(`Unknown error connecting to your store`);
|
|
35
|
-
});
|
|
36
|
-
return data.publicApiVersions
|
|
37
|
-
.filter((item) => item.supported)
|
|
38
|
-
.map((item) => item.handle)
|
|
39
|
-
.sort()
|
|
40
|
-
.reverse()[0];
|
|
41
|
-
}
|
|
42
|
-
function adminUrl(store, version) {
|
|
43
|
-
const realVersion = version || 'unstable';
|
|
44
|
-
return `https://${store}/admin/api/${realVersion}/graphql.json`;
|
|
45
|
-
}
|
|
46
|
-
function apiVersionQuery() {
|
|
47
|
-
return gql `
|
|
48
|
-
query {
|
|
49
|
-
publicApiVersions {
|
|
50
|
-
handle
|
|
51
|
-
supported
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
`;
|
|
55
|
-
}
|
|
56
|
-
//# sourceMappingURL=admin.js.map
|
package/dist/api/admin.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"admin.js","sourceRoot":"","sources":["../../src/api/admin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,eAAe,EAAE,cAAc,EAAC,MAAM,aAAa,CAAA;AAEzE,OAAO,EAAC,KAAK,EAAE,OAAO,EAAE,KAAK,IAAI,WAAW,EAAC,MAAM,cAAc,CAAA;AACjE,OAAO,EAAC,GAAG,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AACtC,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAC,GAAG,EAA6B,MAAM,iBAAiB,CAAA;AAE/D,MAAM,CAAC,KAAK,UAAU,OAAO,CAAI,KAAsB,EAAE,OAAqB,EAAE,SAAqB;IACnG,MAAM,GAAG,GAAG,OAAO,CAAA;IACnB,OAAO,cAAc,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE;QACpC,MAAM,OAAO,GAAG,MAAM,eAAe,CAAC,OAAO,CAAC,CAAA;QAC9C,MAAM,GAAG,GAAG,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;QAChD,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QACjD,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,EAAC,OAAO,EAAE,GAAG,EAAC,CAAC,CAAA;QAClD,eAAe,CAAC,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;QAC/C,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO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AA;AAClB,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa,EAAE,OAA2B;IAC1D,MAAM,WAAW,GAAG,OAAO,IAAI,UAAU,CAAA;IACzC,OAAO,WAAW,KAAK,cAAc,WAAW,eAAe,CAAA;AACjE,CAAC;AAED,SAAS,eAAe;IACtB,OAAO,GAAG,CAAA;;;;;;;GAOT,CAAA;AACH,CAAC","sourcesContent":["import {buildHeaders, debugLogRequest, handlingErrors} from './common.js'\nimport {AdminSession} from '../session.js'\nimport {debug, content, token as outputToken} from '../output.js'\nimport {Bug, Abort} from '../error.js'\nimport {graphqlClient} from '../http/graphql.js'\nimport {gql, RequestDocument, Variables} from 'graphql-request'\n\nexport async function request<T>(query: RequestDocument, session: AdminSession, variables?: Variables): Promise<T> {\n const api = 'Admin'\n return handlingErrors(api, async () => {\n const version = await fetchApiVersion(session)\n const url = adminUrl(session.storeFqdn, version)\n const headers = await buildHeaders(session.token)\n const client = await graphqlClient({headers, url})\n debugLogRequest(api, query, variables, headers)\n const response = await client.request<T>(query, variables)\n return response\n })\n}\n\nasync function fetchApiVersion(session: AdminSession): Promise<string> {\n const url = adminUrl(session.storeFqdn, 'unstable')\n const query = apiVersionQuery()\n const headers = await buildHeaders(session.token)\n const client = await graphqlClient({url, headers})\n debug(`\nSending Admin GraphQL request to URL ${url} with query:\n${query}\n `)\n const data = await client\n .request<{\n publicApiVersions: {handle: string; supported: boolean}[]\n }>(query, {})\n .catch((err) => {\n if (err.response.status === 403) {\n const storeName = session.storeFqdn.replace('.myshopify.com', '')\n throw new Abort(\n content`Looks like you don't have access this dev store: (${outputToken.link(\n storeName,\n `https://${session.storeFqdn}`,\n )})`,\n content`If you're not the owner, create a dev store staff account for yourself`,\n )\n }\n throw new Bug(`Unknown error connecting to your store`)\n })\n\n return data.publicApiVersions\n .filter((item) => item.supported)\n .map((item) => item.handle)\n .sort()\n .reverse()[0]!\n}\n\nfunction adminUrl(store: string, version: string | undefined): string {\n const realVersion = version || 'unstable'\n return `https://${store}/admin/api/${realVersion}/graphql.json`\n}\n\nfunction apiVersionQuery(): string {\n return gql`\n query {\n publicApiVersions {\n handle\n supported\n }\n }\n `\n}\n"]}
|
package/dist/api/common.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/api/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,yBAAyB,CAAA;AACrD,OAAO,SAAS,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAC,gBAAgB,EAAE,OAAO,EAAE,KAAK,IAAI,WAAW,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,cAAc,CAAA;AAC1F,OAAO,EAAC,KAAK,EAAE,eAAe,EAAC,MAAM,aAAa,CAAA;AAClD,OAAO,EAAC,WAAW,EAA6B,MAAM,iBAAiB,CAAA;AACvE,OAAO,EAAC,UAAU,EAAC,MAAM,QAAQ,CAAA;AAEjC,MAAM,OAAO,kBAAmB,SAAQ,eAAe;IAErD,YAAmB,OAAe,EAAE,UAAkB;QACpD,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;CACF;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,KAAc;IAC/C,MAAM,SAAS,GAAG,kBAAkB,MAAM,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAA;IAEvE,MAAM,OAAO,GAA+B;QAC1C,YAAY,EAAE,SAAS;QACvB,0DAA0D;QAC1D,oBAAoB,EAAE,OAAO,CAAC,QAAQ;QACtC,cAAc,EAAE,UAAU,EAAE;QAC5B,cAAc,EAAE,kBAAkB;QAClC,GAAG,CAAC,aAAa,EAAE,IAAI,EAAC,wBAAwB,EAAE,GAAG,EAAC,CAAC;KACxD,CAAA;IACD,IAAI,KAAK,EAAE;QACT,wCAAwC;QACxC,OAAO,CAAC,eAAe,CAAC,GAAG,UAAU,KAAK,EAAE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K,UAAU,cAAc,CAAI,GAAW,EAAE,MAAwB;IAC3E,IAAI;QACF,OAAO,MAAM,MAAM,EAAE,CAAA;KACtB;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,KAAK,YAAY,WAAW,EAAE;YAChC,MAAM,YAAY,GAAG,gBAAgB,CAAC,OAAO,CAAA;QAC3C,KAAK,CAAC,GAAG,CACb,GAAG,CACJ,8DAA8D,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE;;IAEvF,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;OACpC,CAAC,CAAA;YACF,IAAI,WAAkB,CAAA;YACtB,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,GAAG,EAAE;gBAC/B,WAAW,GAAG,IAAI,kBAAkB,CAAC,YAAY,EAAE,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;aAC1E;iBAAM;gBACL,WAAW,GAAG,IAAI,KAAK,CAAC,YAAY,CAAC,CAAA;aACtC;YACD,WAAW,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAA;YAC/B,MAAM,WAAW,CAAA;SAClB;aAAM;YACL,MAAM,KAAK,CAAA;SACZ;KACF;AACH,CAAC","sourcesContent":["import {firstPartyDev} from '../environment/local.js'\nimport constants from '../constants.js'\nimport {stringifyMessage, content, token as outputToken, token, debug} from '../output.js'\nimport {Abort, ExtendableError} from '../error.js'\nimport {ClientError, RequestDocument, Variables} from 'graphql-request'\nimport {randomUUID} from 'crypto'\n\nexport class RequestClientError extends ExtendableError {\n statusCode: number\n public constructor(message: string, statusCode: number) {\n super(message)\n this.statusCode = statusCode\n }\n}\n\nexport async function buildHeaders(token?: string): Promise<{[key: string]: string}> {\n const userAgent = `Shopify CLI; v=${await constants.versions.cliKit()}`\n\n const headers: {[header: string]: string} = {\n 'User-Agent': userAgent,\n // 'Sec-CH-UA': secCHUA, This header requires the Git sha.\n 'Sec-CH-UA-PLATFORM': process.platform,\n 'X-Request-Id': randomUUID(),\n 'Content-Type': 'application/json',\n ...(firstPartyDev() && {'X-Shopify-Cli-Employee': '1'}),\n }\n if (token) {\n // eslint-disable-next-line dot-notation\n headers['authorization'] = `Bearer ${token}`\n headers['X-Shopify-Access-Token'] = `Bearer ${token}`\n }\n\n return headers\n}\n\n/**\n * Removes the sensitive data from the headers and outputs them as a string.\n * @param headers - HTTP headers.\n * @returns A sanitized version of the headers as a string.\n */\nexport function sanitizedHeadersOutput(headers: {[key: string]: string}): string {\n const sanitized: {[key: string]: string} = {}\n const keywords = ['token', 'authorization']\n Object.keys(headers).forEach((header) => {\n if (keywords.find((keyword) => header.toLocaleLowerCase().includes(keyword)) === undefined) {\n sanitized[header] = headers[header]!\n }\n })\n return Object.keys(sanitized)\n .map((header) => {\n return ` - ${header}: ${sanitized[header]}`\n })\n .join('\\n')\n}\n\nexport function debugLogRequest<T>(\n api: string,\n query: RequestDocument,\n variables?: Variables,\n headers: {[key: string]: string} = {},\n) {\n debug(content`\nSending ${token.json(api)} GraphQL request:\n${token.raw(query.toString())}\n\nWith variables:\n${variables ? JSON.stringify(variables, null, 2) : ''}\n\nAnd headers:\n${sanitizedHeadersOutput(headers)}\n`)\n}\n\nexport async function handlingErrors<T>(api: string, action: () => Promise<T>): Promise<T> {\n try {\n return await action()\n } catch (error) {\n if (error instanceof ClientError) {\n const errorMessage = stringifyMessage(content`\n The ${token.raw(\n api,\n )} GraphQL API responded unsuccessfully with the HTTP status ${`${error.response.status}`} and errors:\n\n ${outputToken.json(error.response.errors)}\n `)\n let mappedError: Error\n if (error.response.status < 500) {\n mappedError = new RequestClientError(errorMessage, error.response.status)\n } else {\n mappedError = new Abort(errorMessage)\n }\n mappedError.stack = error.stack\n throw mappedError\n } else {\n throw error\n }\n }\n}\n"]}
|
package/dist/api/identity.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/api/identity.ts"],"names":[],"mappings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AAO,KAAK,EAAE;QACd,KAAK,CAAC,kCAAkC,KAAK,EAAE,CAAC,CAAA;QAChD,OAAO,KAAK,CAAA;KACb;AACH,CAAC;AAED,KAAK,UAAU,yBAAyB;IACtC,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,WAAW,MAAM,QAAQ,EAAE,wCAAwC,CAAC,CAAA;IACxG,8DAA8D;IAC9D,MAAM,IAAI,GAAQ,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;IACvC,OAAO,IAAI,CAAC,sBAAsB,CAAA;AACpC,CAAC","sourcesContent":["import {identity} from '../environment/fqdn.js'\nimport {debug} from '../output.js'\nimport {shopifyFetch} from '../http.js'\n\nexport async function validateIdentityToken(token: string) {\n try {\n const instrospectionURL = await getInstrospectionEndpoint()\n const options = {\n method: 'POST',\n headers: {Authorization: `Bearer ${token}`, 'Content-Type': 'application/json'},\n body: JSON.stringify({token}),\n }\n debug(`Sending Identity Introspection request to URL: ${instrospectionURL}`)\n\n const response = await shopifyFetch(instrospectionURL, options)\n\n if (response.ok && response.headers.get('content-type')?.includes('json')) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const json: any = await response.json()\n debug(`The identity token is valid: ${json.valid}`)\n return json.valid\n } else {\n const text = await response.text()\n debug(`The Introspection request failed with:\n - status: ${response.status}\n - www-authenticate header: ${JSON.stringify(response.headers.get('www-authenticate'))}\n - body: ${JSON.stringify(text)}`)\n return false\n }\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n debug(`The identity token is invalid: ${error}`)\n return false\n }\n}\n\nasync function getInstrospectionEndpoint(): Promise<string> {\n const response = await shopifyFetch(`https://${await identity()}/.well-known/openid-configuration.json`)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const json: any = await response.json()\n return json.introspection_endpoint\n}\n"]}
|
package/dist/api/oxygen.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { Variables, RequestDocument } from 'graphql-request';
|
|
2
|
-
import FormData from 'form-data';
|
|
3
|
-
import { Response } from 'node-fetch';
|
|
4
|
-
export declare function request<T>(oxygenAddress: string, query: RequestDocument, token: string, variables?: Variables): Promise<T>;
|
|
5
|
-
export declare function uploadDeploymentFile(oxygenAddress: string, token: string, data: FormData): Promise<Response>;
|
package/dist/api/oxygen.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { buildHeaders, debugLogRequest } from './common.js';
|
|
2
|
-
import { graphqlClient } from '../http/graphql.js';
|
|
3
|
-
import { shopifyFetch } from '../http.js';
|
|
4
|
-
export async function request(oxygenAddress, query, token, variables) {
|
|
5
|
-
const headers = await buildHeaders(token);
|
|
6
|
-
debugLogRequest('Oxygen', query, variables, headers);
|
|
7
|
-
const client = await graphqlClient({
|
|
8
|
-
headers,
|
|
9
|
-
url: getOxygenAddress(oxygenAddress),
|
|
10
|
-
});
|
|
11
|
-
const response = await client.request(query, variables);
|
|
12
|
-
return response;
|
|
13
|
-
}
|
|
14
|
-
export async function uploadDeploymentFile(oxygenAddress, token, data) {
|
|
15
|
-
const headers = await buildHeaders(token);
|
|
16
|
-
delete headers['Content-Type'];
|
|
17
|
-
const response = await shopifyFetch(getOxygenAddress(oxygenAddress), {
|
|
18
|
-
method: 'POST',
|
|
19
|
-
body: data,
|
|
20
|
-
headers: {
|
|
21
|
-
...headers,
|
|
22
|
-
...data.getHeaders(),
|
|
23
|
-
},
|
|
24
|
-
});
|
|
25
|
-
return response;
|
|
26
|
-
}
|
|
27
|
-
const getOxygenAddress = (oxygenHost) => {
|
|
28
|
-
return `https://${oxygenHost}/api/graphql/deploy/v1`;
|
|
29
|
-
};
|
|
30
|
-
//# sourceMappingURL=oxygen.js.map
|
package/dist/api/oxygen.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"oxygen.js","sourceRoot":"","sources":["../../src/api/oxygen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,eAAe,EAAC,MAAM,aAAa,CAAA;AACzD,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAC,YAAY,EAAC,MAAM,YAAY,CAAA;AAKvC,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,aAAqB,EACrB,KAAsB,EACtB,KAAa,EACb,SAAqB;IAErB,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,KAAK,CAAC,CAAA;IACzC,eAAe,CAAC,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;IACpD,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC;QACjC,OAAO;QACP,GAAG,EAAE,gBAAgB,CAAC,aAAa,CAAC;KACrC,CAAC,CAAA;IAEF,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CAAI,KAAK,EAAE,SAAS,CAAC,CAAA;IAC1D,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,aAAqB,EAAE,KAAa,EAAE,IAAc;IAC7F,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,KAAK,CAAC,CAAA;IACzC,OAAO,OAAO,CAAC,cAAc,CAAC,CAAA;IAE9B,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,gBAAgB,CAAC,aAAa,CAAC,EAAE;QACnE,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,IAAI;QACV,OAAO,EAAE;YACP,GAAG,OAAO;YACV,GAAG,IAAI,CAAC,UAAU,EAAE;SACrB;KACF,CAAC,CAAA;IAEF,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED,MAAM,gBAAgB,GAAG,CAAC,UAAkB,EAAU,EAAE;IACtD,OAAO,WAAW,UAAU,wBAAwB,CAAA;AACtD,CAAC,CAAA","sourcesContent":["import {buildHeaders, debugLogRequest} from './common.js'\nimport {graphqlClient} from '../http/graphql.js'\nimport {shopifyFetch} from '../http.js'\nimport {Variables, RequestDocument} from 'graphql-request'\nimport FormData from 'form-data'\nimport {Response} from 'node-fetch'\n\nexport async function request<T>(\n oxygenAddress: string,\n query: RequestDocument,\n token: string,\n variables?: Variables,\n): Promise<T> {\n const headers = await buildHeaders(token)\n debugLogRequest('Oxygen', query, variables, headers)\n const client = await graphqlClient({\n headers,\n url: getOxygenAddress(oxygenAddress),\n })\n\n const response = await client.request<T>(query, variables)\n return response\n}\n\nexport async function uploadDeploymentFile(oxygenAddress: string, token: string, data: FormData): Promise<Response> {\n const headers = await buildHeaders(token)\n delete headers['Content-Type']\n\n const response = await shopifyFetch(getOxygenAddress(oxygenAddress), {\n method: 'POST',\n body: data,\n headers: {\n ...headers,\n ...data.getHeaders(),\n },\n })\n\n return response\n}\n\nconst getOxygenAddress = (oxygenHost: string): string => {\n return `https://${oxygenHost}/api/graphql/deploy/v1`\n}\n"]}
|
package/dist/api/partners.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { buildHeaders, debugLogRequest, handlingErrors } from './common.js';
|
|
2
|
-
import { ScriptServiceProxyQuery } from './graphql/index.js';
|
|
3
|
-
import { partners as partnersFqdn } from '../environment/fqdn.js';
|
|
4
|
-
import { graphqlClient } from '../http/graphql.js';
|
|
5
|
-
import { debug } from '../output.js';
|
|
6
|
-
import { performance } from 'perf_hooks';
|
|
7
|
-
export async function request(query, token, variables) {
|
|
8
|
-
const api = 'Partners';
|
|
9
|
-
return handlingErrors(api, async () => {
|
|
10
|
-
const fqdn = await partnersFqdn();
|
|
11
|
-
const url = `https://${fqdn}/api/cli/graphql`;
|
|
12
|
-
const headers = await buildHeaders(token);
|
|
13
|
-
debugLogRequest(api, query, variables, headers);
|
|
14
|
-
const client = await graphqlClient({ headers, url });
|
|
15
|
-
const t0 = performance.now();
|
|
16
|
-
const response = await client.request(query, variables);
|
|
17
|
-
const t1 = performance.now();
|
|
18
|
-
debug(`Request to ${url.toString()} completed in ${Math.round(t1 - t0)} ms`);
|
|
19
|
-
return response;
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Function queries are proxied through the script service proxy.
|
|
24
|
-
* To execute a query, we encapsulate it inside another query (including the variables)
|
|
25
|
-
* This is done automatically, you just need to provide the query and the variables.
|
|
26
|
-
*
|
|
27
|
-
* @param apiKey - APIKey of the app where the query will be executed.
|
|
28
|
-
* @param query - GraphQL query to execute.
|
|
29
|
-
* @param token - Partners token
|
|
30
|
-
* @param variables - GraphQL variables to pass to the query.
|
|
31
|
-
* @returns The response of the query.
|
|
32
|
-
*/
|
|
33
|
-
export async function functionProxyRequest(apiKey, query, token, variables) {
|
|
34
|
-
const proxyVariables = {
|
|
35
|
-
api_key: apiKey,
|
|
36
|
-
query,
|
|
37
|
-
variables: JSON.stringify(variables) || '{}',
|
|
38
|
-
};
|
|
39
|
-
const proxyQuery = ScriptServiceProxyQuery;
|
|
40
|
-
const res = await request(proxyQuery, token, proxyVariables);
|
|
41
|
-
const json = JSON.parse(res.scriptServiceProxy);
|
|
42
|
-
return json;
|
|
43
|
-
}
|
|
44
|
-
//# sourceMappingURL=partners.js.map
|
package/dist/api/partners.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"partners.js","sourceRoot":"","sources":["../../src/api/partners.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,eAAe,EAAE,cAAc,EAAC,MAAM,aAAa,CAAA;AACzE,OAAO,EAAC,uBAAuB,EAAC,MAAM,oBAAoB,CAAA;AAC1D,OAAO,EAAC,QAAQ,IAAI,YAAY,EAAC,MAAM,wBAAwB,CAAA;AAC/D,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAC,KAAK,EAAC,MAAM,cAAc,CAAA;AAElC,OAAO,EAAC,WAAW,EAAC,MAAM,YAAY,CAAA;AAEtC,MAAM,CAAC,KAAK,UAAU,OAAO,CAAI,KAAsB,EAAE,KAAa,EAAE,SAAqB;IAC3F,MAAM,GAAG,GAAG,UAAU,CAAA;I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ClB,CAAC","sourcesContent":["import {buildHeaders, debugLogRequest, handlingErrors} from './common.js'\nimport {ScriptServiceProxyQuery} from './graphql/index.js'\nimport {partners as partnersFqdn} from '../environment/fqdn.js'\nimport {graphqlClient} from '../http/graphql.js'\nimport {debug} from '../output.js'\nimport {Variables, RequestDocument} from 'graphql-request'\nimport {performance} from 'perf_hooks'\n\nexport async function request<T>(query: RequestDocument, token: string, variables?: Variables): Promise<T> {\n const api = 'Partners'\n return handlingErrors(api, async () => {\n const fqdn = await partnersFqdn()\n const url = `https://${fqdn}/api/cli/graphql`\n const headers = await buildHeaders(token)\n debugLogRequest(api, query, variables, headers)\n const client = await graphqlClient({headers, url})\n const t0 = performance.now()\n const response = await client.request<T>(query, variables)\n const t1 = performance.now()\n debug(`Request to ${url.toString()} completed in ${Math.round(t1 - t0)} ms`)\n return response\n })\n}\n\ninterface ProxyResponse {\n scriptServiceProxy: string\n}\n\n/**\n * Function queries are proxied through the script service proxy.\n * To execute a query, we encapsulate it inside another query (including the variables)\n * This is done automatically, you just need to provide the query and the variables.\n *\n * @param apiKey - APIKey of the app where the query will be executed.\n * @param query - GraphQL query to execute.\n * @param token - Partners token\n * @param variables - GraphQL variables to pass to the query.\n * @returns The response of the query.\n */\nexport async function functionProxyRequest<T>(\n apiKey: string,\n query: unknown,\n token: string,\n variables?: unknown,\n): Promise<T> {\n const proxyVariables = {\n api_key: apiKey,\n query,\n variables: JSON.stringify(variables) || '{}',\n }\n const proxyQuery = ScriptServiceProxyQuery\n const res: ProxyResponse = await request(proxyQuery, token, proxyVariables)\n const json = JSON.parse(res.scriptServiceProxy)\n return json as T\n}\n"]}
|
package/dist/http/graphql.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { GraphQLClient } from 'graphql-request';
|
|
2
|
-
interface GraphqlClientOptions {
|
|
3
|
-
url: string;
|
|
4
|
-
headers: {
|
|
5
|
-
[key: string]: string;
|
|
6
|
-
};
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Creates a GraphQLClient instance with the right HTTPs agent baed on the service
|
|
10
|
-
* the client will interact with.
|
|
11
|
-
*/
|
|
12
|
-
export declare function graphqlClient(options: GraphqlClientOptions): Promise<GraphQLClient>;
|
|
13
|
-
export {};
|
package/dist/http/graphql.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { httpsAgent } from '../http.js';
|
|
2
|
-
import { GraphQLClient } from 'graphql-request';
|
|
3
|
-
/**
|
|
4
|
-
* Creates a GraphQLClient instance with the right HTTPs agent baed on the service
|
|
5
|
-
* the client will interact with.
|
|
6
|
-
*/
|
|
7
|
-
export async function graphqlClient(options) {
|
|
8
|
-
const clientOptions = { agent: await httpsAgent(), headers: options.headers };
|
|
9
|
-
const client = new GraphQLClient(options.url, clientOptions);
|
|
10
|
-
return client;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=graphql.js.map
|
package/dist/http/graphql.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"graphql.js","sourceRoot":"","sources":["../../src/http/graphql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAA;AAO7C;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAA6B;IAC/D,MAAM,aAAa,GAAG,EAAC,KAAK,EAAE,MAAM,UAAU,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAC,CAAA;IAC3E,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,OAAO,CAAC,GAAG,EAAE,aAAa,CAAC,CAAA;IAC5D,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import {httpsAgent} from '../http.js'\nimport {GraphQLClient} from 'graphql-request'\n\ninterface GraphqlClientOptions {\n url: string\n headers: {[key: string]: string}\n}\n\n/**\n * Creates a GraphQLClient instance with the right HTTPs agent baed on the service\n * the client will interact with.\n */\nexport async function graphqlClient(options: GraphqlClientOptions) {\n const clientOptions = {agent: await httpsAgent(), headers: options.headers}\n const client = new GraphQLClient(options.url, clientOptions)\n return client\n}\n"]}
|
package/dist/os.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
export declare const username: (platform?: NodeJS.Platform) => Promise<string | null>;
|
|
4
|
-
/**
|
|
5
|
-
* Returns the platform and architecture.
|
|
6
|
-
* @returns Returns the current platform and architecture.
|
|
7
|
-
*/
|
|
8
|
-
export declare const platformAndArch: (platform?: NodeJS.Platform) => {
|
|
9
|
-
platform: string;
|
|
10
|
-
arch: string;
|
|
11
|
-
};
|
package/dist/os.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"os.js","sourceRoot":"","sources":["../src/os.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAE,OAAO,EAAC,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAC,KAAK,EAAC,MAAM,OAAO,CAAA;AAC3B,OAAO,EAAC,QAAQ,IAAI,UAAU,EAAE,IAAI,IAAI,MAAM,EAAC,MAAM,IAAI,CAAA;AAEzD,MAAM,sBAAsB,GAAG,GAAG,EAAE;IAClC,MAAM,EAAC,GAAG,EAAC,GAAG,OAAO,CAAA;IAErB,OAAO,GAAG,CAAC,SAAS,IAAI,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,QAAQ,CAAA;AAC7F,CAAC,CAAA;AAED,MAAM,yBAAyB,GAAG,GAAkB,EAAE;IACpD,IAAI;QACF,OAAO,UAAU,EAAE,CAAC,QAAQ,CAAA;QAC5B,qDAAqD;KACtD;IAAC,MAAM;QACN,OAAO,IAAI,CAAA;KACZ;AACH,CAAC,CAAA;AAED,MAAM,mBAAmB,GA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CAAC,QAAQ,EAClB,EAAE;IACpC,IAAI,IAAI,GAAG,MAAM,EAAE,CAAA;IACnB,IAAI,IAAI,KAAK,KAAK,EAAE;QAClB,IAAI,GAAG,OAAO,CAAA;KACf;IACD,IAAI,IAAI,KAAK,MAAM,EAAE;QACnB,IAAI,GAAG,KAAK,CAAA;KACb;IACD,IAAI,cAAc,GAAG,QAAkB,CAAA;IACvC,IAAI,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE;QAC5B,cAAc,GAAG,SAAS,CAAA;KAC3B;IACD,OAAO,EAAC,QAAQ,EAAE,cAAc,EAAE,IAAI,EAAC,CAAA;AACzC,CAAC,CAAA","sourcesContent":["import {debug, content} from './output.js'\nimport {execa} from 'execa'\nimport {userInfo as osUserInfo, arch as osArch} from 'os'\n\nconst getEnvironmentVariable = () => {\n const {env} = process\n\n return env.SUDO_USER || env.C9_USER || env.LOGNAME || env.USER || env.LNAME || env.USERNAME\n}\n\nconst getUsernameFromOsUserInfo = (): string | null => {\n try {\n return osUserInfo().username\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return null\n }\n}\n\nconst cleanWindowsCommand = (value: string) => value.replace(/^.*\\\\/, '')\n\nconst makeUsernameFromId = (userId: string) => `no-username-${userId}`\n\n// This code has been vendored from https://github.com/sindresorhus/username\n// because adding it as a transtive dependency causes conflicts with other\n// packages that haven't been yet migrated to the latest version.\nexport const username = async (platform: typeof process.platform = process.platform): Promise<string | null> => {\n debug(content`Obtaining user name...`)\n const environmentVariable = getEnvironmentVariable()\n if (environmentVariable) {\n return environmentVariable\n }\n\n const userInfoUsername = getUsernameFromOsUserInfo()\n if (userInfoUsername) {\n return userInfoUsername\n }\n\n /**\n\tFirst we try to get the ID of the user and then the actual username. We do this because in `docker run --user <uid>:<gid>` context, we don't have \"username\" available. Therefore, we have a fallback to `makeUsernameFromId` for such scenario. Applies also to the `sync()` method below.\n\t*/\n try {\n if (platform === 'win32') {\n const {stdout} = await execa('whoami')\n return cleanWindowsCommand(stdout)\n }\n\n const {stdout: userId} = await execa('id', ['-u'])\n try {\n const {stdout} = await execa('id', ['-un', userId])\n return stdout\n\n // eslint-disable-next-line no-catch-all/no-catch-all,no-empty\n } catch {}\n return makeUsernameFromId(userId)\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return null\n }\n}\n\n/**\n * Returns the platform and architecture.\n * @returns Returns the current platform and architecture.\n */\nexport const platformAndArch = (\n platform: typeof process.platform = process.platform,\n): {platform: string; arch: string} => {\n let arch = osArch()\n if (arch === 'x64') {\n arch = 'amd64'\n }\n if (arch === 'ia32') {\n arch = '386'\n }\n let platformString = platform as string\n if (platform.match(/^win.+/)) {\n platformString = 'windows'\n }\n return {platform: platformString, arch}\n}\n"]}
|
package/dist/string.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export { camelCase as camelize } from 'change-case';
|
|
2
|
-
export { paramCase as hyphenize } from 'change-case';
|
|
3
|
-
export { snakeCase as underscore } from 'change-case';
|
|
4
|
-
export { constantCase as constantize } from 'change-case';
|
|
5
|
-
/** Returns a random string */
|
|
6
|
-
export declare function randomHex(size: number): string;
|
|
7
|
-
export declare function generateRandomChallengePair(): {
|
|
8
|
-
codeVerifier: string;
|
|
9
|
-
codeChallenge: string;
|
|
10
|
-
};
|
|
11
|
-
export declare function hashString(str: string): string;
|
|
12
|
-
/**
|
|
13
|
-
* Given a string, it returns it with the first letter capitalized.
|
|
14
|
-
* @param string - String whose first letter will be caplitalized.
|
|
15
|
-
* @returns The given string with its first letter capitalized.
|
|
16
|
-
*/
|
|
17
|
-
export declare function capitalize(string: string): string;
|
|
18
|
-
/**
|
|
19
|
-
* Try to convert a string to an int, falling back to undefined if unable to
|
|
20
|
-
*/
|
|
21
|
-
export declare function tryParseInt(maybeInt: string | undefined): number | undefined;
|
|
22
|
-
/**
|
|
23
|
-
* Given a series of rows inside an array, where each row is an array of strings (representing columns)
|
|
24
|
-
* Parse it into a single string with the columns aligned
|
|
25
|
-
*/
|
|
26
|
-
export declare function linesToColumns(lines: string[][]): string;
|
|
27
|
-
export declare const slugify: (str: string) => string;
|
|
28
|
-
export declare const escapeRegExp: (str: string) => string;
|
package/dist/string.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { unstyled } from './output.js';
|
|
2
|
-
import crypto from 'crypto';
|
|
3
|
-
export { camelCase as camelize } from 'change-case';
|
|
4
|
-
export { paramCase as hyphenize } from 'change-case';
|
|
5
|
-
export { snakeCase as underscore } from 'change-case';
|
|
6
|
-
export { constantCase as constantize } from 'change-case';
|
|
7
|
-
/** Returns a random string */
|
|
8
|
-
export function randomHex(size) {
|
|
9
|
-
return crypto.randomBytes(size).toString('hex');
|
|
10
|
-
}
|
|
11
|
-
export function generateRandomChallengePair() {
|
|
12
|
-
const codeVerifier = base64URLEncode(crypto.randomBytes(32));
|
|
13
|
-
const codeChallenge = base64URLEncode(sha256(codeVerifier));
|
|
14
|
-
return { codeVerifier, codeChallenge };
|
|
15
|
-
}
|
|
16
|
-
function base64URLEncode(str) {
|
|
17
|
-
return str.toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/[=]/g, '');
|
|
18
|
-
}
|
|
19
|
-
function sha256(str) {
|
|
20
|
-
return crypto.createHash('sha256').update(str).digest();
|
|
21
|
-
}
|
|
22
|
-
export function hashString(str) {
|
|
23
|
-
return crypto.createHash('sha1').update(str).digest('hex');
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Given a string, it returns it with the first letter capitalized.
|
|
27
|
-
* @param string - String whose first letter will be caplitalized.
|
|
28
|
-
* @returns The given string with its first letter capitalized.
|
|
29
|
-
*/
|
|
30
|
-
export function capitalize(string) {
|
|
31
|
-
return string.substring(0, 1).toUpperCase() + string.substring(1);
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Try to convert a string to an int, falling back to undefined if unable to
|
|
35
|
-
*/
|
|
36
|
-
export function tryParseInt(maybeInt) {
|
|
37
|
-
let asInt;
|
|
38
|
-
if (maybeInt !== undefined) {
|
|
39
|
-
asInt = parseInt(maybeInt, 10);
|
|
40
|
-
if (isNaN(asInt)) {
|
|
41
|
-
asInt = undefined;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return asInt;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Given a series of rows inside an array, where each row is an array of strings (representing columns)
|
|
48
|
-
* Parse it into a single string with the columns aligned
|
|
49
|
-
*/
|
|
50
|
-
export function linesToColumns(lines) {
|
|
51
|
-
const widths = [];
|
|
52
|
-
for (let i = 0; lines[0] && i < lines[0].length; i++) {
|
|
53
|
-
const columnRows = lines.map((line) => line[i]);
|
|
54
|
-
widths.push(Math.max(...columnRows.map((row) => unstyled(row).length)));
|
|
55
|
-
}
|
|
56
|
-
const paddedLines = lines
|
|
57
|
-
.map((line) => {
|
|
58
|
-
return line
|
|
59
|
-
.map((col, index) => {
|
|
60
|
-
return `${col}${' '.repeat(widths[index] - unstyled(col).length)}`;
|
|
61
|
-
})
|
|
62
|
-
.join(' ')
|
|
63
|
-
.trimEnd();
|
|
64
|
-
})
|
|
65
|
-
.join('\n');
|
|
66
|
-
return paddedLines;
|
|
67
|
-
}
|
|
68
|
-
export const slugify = (str) => str
|
|
69
|
-
.toLowerCase()
|
|
70
|
-
.trim()
|
|
71
|
-
.replace(/[^\w\s-]/g, '')
|
|
72
|
-
.replace(/[\s_-]+/g, '-')
|
|
73
|
-
.replace(/^-+|-+$/g, '');
|
|
74
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping
|
|
75
|
-
// $& means the whole matched string
|
|
76
|
-
export const escapeRegExp = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
77
|
-
//# sourceMappingURL=string.js.map
|
package/dist/string.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"string.js","sourceRoot":"","sources":["../src/string.ts"],"names":[],"mappings":"A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M,CAAC,KAAK,CAAE,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAA;QACrE,CAAC,CAAC;aACD,IAAI,CAAC,KAAK,CAAC;aACX,OAAO,EAAE,CAAA;IACd,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAA;IACb,OAAO,WAAW,CAAA;AACpB,CAAC;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,GAAW,EAAE,EAAE,CACrC,GAAG;KACA,WAAW,EAAE;KACb,IAAI,EAAE;KACN,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;KACxB,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC;KACxB,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAA;AAE5B,6FAA6F;AAC7F,oCAAoC;AACpC,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAA","sourcesContent":["import {unstyled} from './output.js'\nimport crypto from 'crypto'\n\nexport {camelCase as camelize} from 'change-case'\nexport {paramCase as hyphenize} from 'change-case'\nexport {snakeCase as underscore} from 'change-case'\nexport {constantCase as constantize} from 'change-case'\n\n/** Returns a random string */\nexport function randomHex(size: number): string {\n return crypto.randomBytes(size).toString('hex')\n}\n\nexport function generateRandomChallengePair() {\n const codeVerifier = base64URLEncode(crypto.randomBytes(32))\n const codeChallenge = base64URLEncode(sha256(codeVerifier))\n return {codeVerifier, codeChallenge}\n}\n\nfunction base64URLEncode(str: Buffer) {\n return str.toString('base64').replace(/\\+/g, '-').replace(/\\//g, '_').replace(/[=]/g, '')\n}\n\nfunction sha256(str: string) {\n return crypto.createHash('sha256').update(str).digest()\n}\n\nexport function hashString(str: string): string {\n return crypto.createHash('sha1').update(str).digest('hex')\n}\n\n/**\n * Given a string, it returns it with the first letter capitalized.\n * @param string - String whose first letter will be caplitalized.\n * @returns The given string with its first letter capitalized.\n */\nexport function capitalize(string: string) {\n return string.substring(0, 1).toUpperCase() + string.substring(1)\n}\n\n/**\n * Try to convert a string to an int, falling back to undefined if unable to\n */\nexport function tryParseInt(maybeInt: string | undefined) {\n let asInt: number | undefined\n if (maybeInt !== undefined) {\n asInt = parseInt(maybeInt, 10)\n if (isNaN(asInt)) {\n asInt = undefined\n }\n }\n return asInt\n}\n\n/**\n * Given a series of rows inside an array, where each row is an array of strings (representing columns)\n * Parse it into a single string with the columns aligned\n */\nexport function linesToColumns(lines: string[][]): string {\n const widths: number[] = []\n for (let i = 0; lines[0] && i < lines[0].length; i++) {\n const columnRows = lines.map((line) => line[i]!)\n widths.push(Math.max(...columnRows.map((row) => unstyled(row).length)))\n }\n const paddedLines = lines\n .map((line) => {\n return line\n .map((col, index) => {\n return `${col}${' '.repeat(widths[index]! - unstyled(col).length)}`\n })\n .join(' ')\n .trimEnd()\n })\n .join('\\n')\n return paddedLines\n}\n\nexport const slugify = (str: string) =>\n str\n .toLowerCase()\n .trim()\n .replace(/[^\\w\\s-]/g, '')\n .replace(/[\\s_-]+/g, '-')\n .replace(/^-+|-+$/g, '')\n\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping\n// $& means the whole matched string\nexport const escapeRegExp = (str: string) => str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n"]}
|
package/dist/template.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"template.js","sourceRoot":"","sources":["../src/template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAC,MAAM,WAAW,CAAA;AACvD,OAAO,EAAC,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,wBAAwB,EAAC,MAAM,WAAW,CAAA;AAChG,OAAO,EAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,aA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AE,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;QACjF,IAAI,MAAM,WAAW,CAAC,gBAAgB,CAAC,EAAE;YACvC,MAAM,KAAK,CAAC,UAAU,CAAC,CAAA;SACxB;aAAM,IAAI,gBAAgB,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;YAC/C,MAAM,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAA;YAChC,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,CAAA;YAC5C,MAAM,aAAa,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAA;YACjD,MAAM,YAAY,GAAG,MAAM,wBAAwB,CAAC,gBAAgB,CAAC,CAAA;YACrE,MAAM,uBAAuB,GAAG,UAAU,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAA;YACjE,MAAM,IAAI,CAAC,gBAAgB,EAAE,uBAAuB,CAAC,CAAA;YACrD,MAAM,KAAK,CAAC,uBAAuB,EAAE,aAAa,CAAC,CAAA;YACnD,IAAI,YAAY,EAAE;gBAChB,MAAM,KAAK,CAAC,uBAAuB,EAAE,KAAK,CAAC,CAAA;aAC5C;SACF;aAAM;YACL,MAAM,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,CAAA;SACzC;IACH,CAAC,CAAC,CACH,CAAA;AACH,CAAC","sourcesContent":["import {glob, join, dirname, relative} from './path.js'\nimport {mkdir, read, copy, chmod, isDirectory, write, hasExecutablePermissions} from './file.js'\nimport {content, token, debug} from './output.js'\nimport {Liquid} from 'liquidjs'\n\n// This line is necessary to register additional helpers.\nexport function create(templateContent: string) {\n return (data: object): Promise<string> => {\n const engine = new Liquid()\n return engine.render(engine.parse(templateContent), data)\n }\n}\n\n/**\n * Given a directory, it traverses the files and directories recursively\n * and replaces variables in directory and file names, and files' content\n * using the Liquid template engine.\n * Files indicate that they are liquid template by using the .liquid extension.\n * @param from - Directory that contains the template.\n * @param to - Output directory.\n * @param data - Data to feed the template engine.\n */\nexport async function recursiveDirectoryCopy(from: string, to: string, data: object) {\n debug(content`Copying template from directory ${token.path(from)} to ${token.path(to)}`)\n const templateFiles: string[] = await glob(join(from, '**/*'), {dot: true})\n\n const sortedTemplateFiles = templateFiles\n .map((path) => path.split('/'))\n .sort((lhs, rhs) => (lhs.length < rhs.length ? 1 : -1))\n .map((components) => components.join('/'))\n await Promise.all(\n sortedTemplateFiles.map(async (templateItemPath) => {\n const outputPath = await create(join(to, relative(from, templateItemPath)))(data)\n if (await isDirectory(templateItemPath)) {\n await mkdir(outputPath)\n } else if (templateItemPath.endsWith('.liquid')) {\n await mkdir(dirname(outputPath))\n const content = await read(templateItemPath)\n const contentOutput = await create(content)(data)\n const isExecutable = await hasExecutablePermissions(templateItemPath)\n const outputPathWithoutLiquid = outputPath.replace('.liquid', '')\n await copy(templateItemPath, outputPathWithoutLiquid)\n await write(outputPathWithoutLiquid, contentOutput)\n if (isExecutable) {\n await chmod(outputPathWithoutLiquid, 0o755)\n }\n } else {\n await copy(templateItemPath, outputPath)\n }\n }),\n )\n}\n"]}
|
package/dist/toml.d.ts
DELETED
package/dist/toml.js
DELETED
package/dist/toml.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"toml.js","sourceRoot":"","sources":["../src/toml.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,aAAa,CAAA;AAEnC,MAAM,UAAU,MAAM,CAAC,KAAa;IAClC,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;AAC1B,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,OAAqB;IAC1C,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;AAChC,CAAC","sourcesContent":["import * as toml from '@iarna/toml'\n\nexport function decode(input: string): object {\n return toml.parse(input)\n}\n\nexport function encode(content: toml.JsonMap): string {\n return toml.stringify(content)\n}\n"]}
|
package/dist/vscode.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Check if user editor is VS Code
|
|
3
|
-
*/
|
|
4
|
-
export declare const isVSCode: (root?: string) => Promise<boolean>;
|
|
5
|
-
/**
|
|
6
|
-
* Add VSCode extension recommendations
|
|
7
|
-
*/
|
|
8
|
-
export declare function addRecommendedExtensions(directory: string, recommendations: string[]): Promise<void>;
|
package/dist/vscode.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vscode.js","sourceRoot":"","sources":["../src/vscode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAC,MAAM,WAAW,CAAA;AAC7C,OAAO,EAAC,MAAM,EAAE,IAAI,EAAC,MAAM,WAAW,CAAA;AACtC,OAAO,EAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AAEjD;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,EAAE,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE,EAAE,EAAE;IACrD,KAAK,CAAC,OAAO,CAAA,6BAA6B,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,oDAAoD,CAAC,CAAA;IAC/G,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,EAAC,IAAI,EAAE,WAAW,EAAC,CAAC,CAAA;IAEvE,IAAI,CAAC,MAAM,EAAE;QACX,OAAO,KAAK,CAAA;KACb;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,CAAA;AACvB,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,SAAiB,EAAE,eAAyB;IACzF,KAAK,CAAC,OAAO,CAAA,2CAA2C,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC;EAC7E,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC;GAC1B,CAAC,CAAA;IACF,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,EAAE,yBAAyB,CAAC,CAAA;IAEjE,IAAI,MAAM,QAAQ,CAAC,SAAS,CAAC,EAAE;QAC7B,IAAI,sBAAsB,GAAG,EAAC,eAAe,EAAE,EAAE,EAAC,CAAA;QAClD,IAAI,MAAM,MAAM,CAAC,cAAc,CAAC,EAAE;YAChC,MAAM,sBAAsB,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,CAAA;YACzD,sBAAsB,GAAG,IAAI,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAA;SAC5D;QACD,MAAM,iBAAiB,GAAG;YACxB,GAAG,sBAAsB;YACzB,eAAe,EAAE,CAAC,GAAG,sBAAsB,CAAC,eAAe,EAAE,GAAG,eAAe,CAAC;SACjF,CAAA;QACD,MAAM,KAAK,CAAC,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;KACxE;AACH,CAAC","sourcesContent":["import {exists, write, read} from './file.js'\nimport {findUp, join} from './path.js'\nimport {content, token, debug} from './output.js'\n\n/**\n * Check if user editor is VS Code\n */\nexport const isVSCode = async (root = process.cwd()) => {\n debug(content`Checking if the directory ${token.path(root)} or any of its parents has a .vscode directory... `)\n const config = await findUp(join(root, '.vscode'), {type: 'directory'})\n\n if (!config) {\n return false\n }\n\n return exists(config)\n}\n\n/**\n * Add VSCode extension recommendations\n */\nexport async function addRecommendedExtensions(directory: string, recommendations: string[]) {\n debug(content`Adding VSCode recommended extensions at ${token.path(directory)}:\n${token.json(recommendations)}\n `)\n const extensionsPath = join(directory, '.vscode/extensions.json')\n\n if (await isVSCode(directory)) {\n let originalExtensionsJson = {recommendations: []}\n if (await exists(extensionsPath)) {\n const originalExtensionsFile = await read(extensionsPath)\n originalExtensionsJson = JSON.parse(originalExtensionsFile)\n }\n const newExtensionsJson = {\n ...originalExtensionsJson,\n recommendations: [...originalExtensionsJson.recommendations, ...recommendations],\n }\n await write(extensionsPath, JSON.stringify(newExtensionsJson, null, 2))\n }\n}\n"]}
|