netlify-cli 12.2.7 → 12.2.8
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/bin/run.mjs +2 -3
- package/npm-shrinkwrap.json +93 -90
- package/package.json +4 -4
- package/scripts/postinstall.mjs +2 -2
- package/src/commands/base-command.mjs +8 -12
- package/src/commands/build/build.mjs +2 -2
- package/src/commands/completion/completion.mjs +3 -3
- package/src/commands/deploy/deploy.mjs +4 -5
- package/src/commands/dev/{dev-exec.cjs → dev-exec.mjs} +5 -5
- package/src/commands/dev/{dev.cjs → dev.mjs} +32 -32
- package/src/commands/dev/index.mjs +1 -0
- package/src/commands/env/{env-clone.cjs → env-clone.mjs} +7 -16
- package/src/commands/env/{env-get.cjs → env-get.mjs} +5 -13
- package/src/commands/env/{env-import.cjs → env-import.mjs} +8 -15
- package/src/commands/env/{env-list.cjs → env-list.mjs} +13 -25
- package/src/commands/env/{env-set.cjs → env-set.mjs} +5 -5
- package/src/commands/env/{env-unset.cjs → env-unset.mjs} +4 -12
- package/src/commands/env/{env.cjs → env.mjs} +7 -9
- package/src/commands/env/index.mjs +1 -0
- package/src/commands/functions/functions-build.mjs +2 -1
- package/src/commands/functions/functions-create.mjs +2 -12
- package/src/commands/functions/functions-invoke.mjs +2 -1
- package/src/commands/functions/functions-list.mjs +2 -1
- package/src/commands/functions/functions-serve.mjs +3 -2
- package/src/commands/graph/{graph-config-write.cjs → graph-config-write.mjs} +8 -8
- package/src/commands/graph/{graph-edit.cjs → graph-edit.mjs} +9 -14
- package/src/commands/graph/{graph-handler.cjs → graph-handler.mjs} +6 -6
- package/src/commands/graph/{graph-init.cjs → graph-init.mjs} +12 -20
- package/src/commands/graph/{graph-library.cjs → graph-library.mjs} +8 -8
- package/src/commands/graph/{graph-operations.cjs → graph-operations.mjs} +7 -7
- package/src/commands/graph/{graph-pull.cjs → graph-pull.mjs} +8 -12
- package/src/commands/graph/{graph.cjs → graph.mjs} +8 -10
- package/src/commands/graph/index.mjs +1 -0
- package/src/commands/init/init.mjs +5 -2
- package/src/commands/link/index.mjs +1 -0
- package/src/commands/link/{link.cjs → link.mjs} +15 -13
- package/src/commands/lm/index.mjs +1 -0
- package/src/commands/lm/{lm-info.cjs → lm-info.mjs} +4 -6
- package/src/commands/lm/{lm-install.cjs → lm-install.mjs} +3 -5
- package/src/commands/lm/{lm-setup.cjs → lm-setup.mjs} +8 -8
- package/src/commands/lm/{lm-uninstall.cjs → lm-uninstall.mjs} +2 -4
- package/src/commands/lm/{lm.cjs → lm.mjs} +5 -7
- package/src/commands/logout/logout.mjs +2 -1
- package/src/commands/main.mjs +10 -12
- package/src/commands/recipes/common.mjs +36 -0
- package/src/commands/recipes/index.mjs +1 -0
- package/src/commands/recipes/{recipes-list.cjs → recipes-list.mjs} +3 -5
- package/src/commands/recipes/{recipes.cjs → recipes.mjs} +12 -10
- package/src/commands/sites/sites-create-template.mjs +3 -1
- package/src/commands/sites/sites-create.mjs +4 -2
- package/src/commands/sites/sites-list.mjs +1 -1
- package/src/commands/unlink/unlink.mjs +2 -1
- package/src/functions-templates/go/hello-world/go.mod +1 -1
- package/src/functions-templates/javascript/stripe-charge/package-lock.json +6 -6
- package/src/functions-templates/javascript/stripe-subscription/package-lock.json +6 -6
- package/src/functions-templates/javascript/token-hider/package-lock.json +6 -6
- package/src/functions-templates/rust/hello-world/Cargo.toml +1 -1
- package/src/functions-templates/typescript/hello-world/package-lock.json +6 -6
- package/src/lib/account.cjs +0 -3
- package/src/lib/{api.cjs → api.mjs} +3 -5
- package/src/lib/{build.cjs → build.mjs} +9 -9
- package/src/lib/completion/constants.mjs +4 -0
- package/src/lib/completion/{generate-autocompletion.cjs → generate-autocompletion.mjs} +6 -6
- package/src/lib/completion/{script.cjs → get-autocompletion.mjs} +1 -25
- package/src/lib/completion/index.mjs +1 -0
- package/src/lib/completion/script.mjs +35 -0
- package/src/lib/edge-functions/{editor-helper.cjs → editor-helper.mjs} +4 -6
- package/src/lib/edge-functions/index.cjs +1 -2
- package/src/lib/exec-fetcher.cjs +0 -2
- package/src/lib/functions/{form-submissions-handler.cjs → form-submissions-handler.mjs} +26 -28
- package/src/lib/functions/{scheduled.cjs → scheduled.mjs} +6 -8
- package/src/lib/functions/{server.cjs → server.mjs} +20 -29
- package/src/lib/geo-location.cjs +1 -1
- package/src/lib/{http-agent.cjs → http-agent.mjs} +7 -8
- package/src/lib/one-graph/{cli-client.cjs → cli-client.mjs} +46 -74
- package/src/lib/one-graph/{cli-netlify-graph.cjs → cli-netlify-graph.mjs} +35 -43
- package/src/recipes/vscode/{index.cjs → index.mjs} +7 -9
- package/src/recipes/vscode/{settings.cjs → settings.mjs} +10 -12
- package/src/utils/{create-stream-promise.cjs → create-stream-promise.mjs} +2 -2
- package/src/utils/{detect-server-settings.cjs → detect-server-settings.mjs} +14 -20
- package/src/utils/functions/constants.mjs +1 -0
- package/src/utils/functions/{functions.cjs → functions.mjs} +6 -8
- package/src/utils/functions/{get-functions.cjs → get-functions.mjs} +4 -25
- package/src/utils/functions/index.mjs +3 -0
- package/src/utils/get-package-json.mjs +16 -0
- package/src/utils/{get-repo-data.cjs → get-repo-data.mjs} +15 -12
- package/src/utils/{gitignore.cjs → gitignore.mjs} +6 -8
- package/src/utils/index.cjs +0 -20
- package/src/utils/{live-tunnel.cjs → live-tunnel.mjs} +8 -10
- package/src/utils/lm/{install.cjs → install.mjs} +26 -25
- package/src/utils/lm/{requirements.cjs → requirements.mjs} +6 -13
- package/src/utils/lm/{steps.cjs → steps.mjs} +6 -8
- package/src/utils/lm/{ui.cjs → ui.mjs} +5 -7
- package/src/utils/{proxy.cjs → proxy.mjs} +31 -34
- package/src/utils/{read-repo-url.cjs → read-repo-url.mjs} +6 -11
- package/src/utils/{state-config.cjs → state-config.mjs} +8 -10
- package/src/utils/telemetry/index.mjs +1 -0
- package/src/utils/telemetry/{request.cjs → request.mjs} +5 -3
- package/src/utils/telemetry/{telemetry.cjs → telemetry.mjs} +12 -14
- package/src/utils/telemetry/{validation.cjs → validation.mjs} +2 -2
- package/src/commands/dev/index.cjs +0 -5
- package/src/commands/env/index.cjs +0 -5
- package/src/commands/graph/index.cjs +0 -5
- package/src/commands/link/index.cjs +0 -6
- package/src/commands/lm/index.cjs +0 -5
- package/src/commands/recipes/common.cjs +0 -33
- package/src/commands/recipes/index.cjs +0 -8
- package/src/lib/completion/constants.cjs +0 -6
- package/src/lib/completion/index.cjs +0 -5
- package/src/utils/functions/constants.cjs +0 -5
- package/src/utils/functions/index.cjs +0 -12
- package/src/utils/telemetry/index.cjs +0 -5
|
@@ -1,21 +1,15 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
error,
|
|
14
|
-
exit,
|
|
15
|
-
getToken,
|
|
16
|
-
log,
|
|
17
|
-
translateFromEnvelopeToMongo,
|
|
18
|
-
} = require('../../utils/index.cjs')
|
|
2
|
+
import { Buffer } from 'buffer'
|
|
3
|
+
import process from 'process'
|
|
4
|
+
|
|
5
|
+
import { OneGraphClient } from 'netlify-onegraph-internal'
|
|
6
|
+
import { v4 as uuidv4 } from 'uuid'
|
|
7
|
+
|
|
8
|
+
import { OneGraphCliClient, ensureCLISession } from '../../lib/one-graph/cli-client.mjs'
|
|
9
|
+
import { getNetlifyGraphConfig } from '../../lib/one-graph/cli-netlify-graph.mjs'
|
|
10
|
+
import utils from '../../utils/index.cjs'
|
|
11
|
+
|
|
12
|
+
const { NETLIFYDEVERR, chalk, error, exit, getToken, log, translateFromEnvelopeToMongo } = utils
|
|
19
13
|
|
|
20
14
|
const { ensureAppForSite, executeCreateApiTokenMutation } = OneGraphCliClient
|
|
21
15
|
|
|
@@ -161,12 +155,10 @@ const graphInit = async (options, command) => {
|
|
|
161
155
|
* @param {import('../base-command.mjs').default} program
|
|
162
156
|
* @returns
|
|
163
157
|
*/
|
|
164
|
-
const createGraphInitCommand = (program) =>
|
|
158
|
+
export const createGraphInitCommand = (program) =>
|
|
165
159
|
program
|
|
166
160
|
.command('graph:init')
|
|
167
161
|
.description('Initialize all the resources for Netlify Graph')
|
|
168
162
|
.action(async (options, command) => {
|
|
169
163
|
await graphInit(options, command)
|
|
170
164
|
})
|
|
171
|
-
|
|
172
|
-
module.exports = { createGraphInitCommand }
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
|
|
2
|
+
import { GraphQL } from 'netlify-onegraph-internal'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
import { readLockfile } from '../../lib/one-graph/cli-client.mjs'
|
|
5
|
+
import {
|
|
6
6
|
buildSchema,
|
|
7
7
|
defaultExampleOperationsDoc,
|
|
8
8
|
extractFunctionsFromOperationDoc,
|
|
@@ -11,8 +11,10 @@ const {
|
|
|
11
11
|
parse,
|
|
12
12
|
readGraphQLOperationsSourceFile,
|
|
13
13
|
readGraphQLSchemaFile,
|
|
14
|
-
}
|
|
15
|
-
|
|
14
|
+
} from '../../lib/one-graph/cli-netlify-graph.mjs'
|
|
15
|
+
import utils from '../../utils/index.cjs'
|
|
16
|
+
|
|
17
|
+
const { NETLIFYDEVERR, chalk, error, log } = utils
|
|
16
18
|
|
|
17
19
|
/**
|
|
18
20
|
* Creates the `netlify graph:library` command
|
|
@@ -79,12 +81,10 @@ const graphLibrary = async (options, command) => {
|
|
|
79
81
|
* @param {import('../base-command.mjs').default} program
|
|
80
82
|
* @returns
|
|
81
83
|
*/
|
|
82
|
-
const createGraphLibraryCommand = (program) =>
|
|
84
|
+
export const createGraphLibraryCommand = (program) =>
|
|
83
85
|
program
|
|
84
86
|
.command('graph:library')
|
|
85
87
|
.description('Generate the Graph function library')
|
|
86
88
|
.action(async (options, command) => {
|
|
87
89
|
await graphLibrary(options, command)
|
|
88
90
|
})
|
|
89
|
-
|
|
90
|
-
module.exports = { createGraphLibraryCommand }
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
|
|
2
|
+
import { GraphQL } from 'netlify-onegraph-internal'
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
import {
|
|
5
5
|
defaultExampleOperationsDoc,
|
|
6
6
|
extractFunctionsFromOperationDoc,
|
|
7
7
|
getNetlifyGraphConfig,
|
|
8
8
|
readGraphQLOperationsSourceFile,
|
|
9
|
-
}
|
|
10
|
-
|
|
9
|
+
} from '../../lib/one-graph/cli-netlify-graph.mjs'
|
|
10
|
+
import utils from '../../utils/index.cjs'
|
|
11
|
+
|
|
12
|
+
const { log } = utils
|
|
11
13
|
|
|
12
14
|
const { parse } = GraphQL
|
|
13
15
|
|
|
@@ -107,12 +109,10 @@ const graphOperations = async (options, command) => {
|
|
|
107
109
|
* @param {import('../base-command.mjs').default} program
|
|
108
110
|
* @returns
|
|
109
111
|
*/
|
|
110
|
-
const createGraphOperationsCommand = (program) =>
|
|
112
|
+
export const createGraphOperationsCommand = (program) =>
|
|
111
113
|
program
|
|
112
114
|
.command('graph:operations')
|
|
113
115
|
.description('List all of the locally available operations')
|
|
114
116
|
.action(async (options, command) => {
|
|
115
117
|
await graphOperations(options, command)
|
|
116
118
|
})
|
|
117
|
-
|
|
118
|
-
module.exports = { createGraphOperationsCommand }
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
/* eslint-disable eslint-comments/disable-enable-pair */
|
|
3
3
|
/* eslint-disable fp/no-loops */
|
|
4
|
-
|
|
4
|
+
import { OneGraphClient } from 'netlify-onegraph-internal'
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
import {
|
|
7
7
|
OneGraphCliClient,
|
|
8
8
|
ensureCLISession,
|
|
9
9
|
handleCliSessionEvent,
|
|
@@ -11,13 +11,11 @@ const {
|
|
|
11
11
|
readLockfile,
|
|
12
12
|
readSchemaIdFromLockfile,
|
|
13
13
|
refetchAndGenerateFromOneGraph,
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
} = require('../../lib/one-graph/cli-netlify-graph.cjs')
|
|
20
|
-
const { NETLIFYDEVERR, chalk, error, log, warn } = require('../../utils/index.cjs')
|
|
14
|
+
} from '../../lib/one-graph/cli-client.mjs'
|
|
15
|
+
import { buildSchema, getNetlifyGraphConfig, readGraphQLSchemaFile } from '../../lib/one-graph/cli-netlify-graph.mjs'
|
|
16
|
+
import utils from '../../utils/index.cjs'
|
|
17
|
+
|
|
18
|
+
const { NETLIFYDEVERR, chalk, error, log, warn } = utils
|
|
21
19
|
|
|
22
20
|
/**
|
|
23
21
|
* Creates the `netlify graph:pull` command
|
|
@@ -163,12 +161,10 @@ ${JSON.stringify(error_, null, 2)}`)
|
|
|
163
161
|
* @param {import('../base-command.mjs').default} program
|
|
164
162
|
* @returns
|
|
165
163
|
*/
|
|
166
|
-
const createGraphPullCommand = (program) =>
|
|
164
|
+
export const createGraphPullCommand = (program) =>
|
|
167
165
|
program
|
|
168
166
|
.command('graph:pull')
|
|
169
167
|
.description('Pull your remote Netlify Graph schema locally, and process pending Graph edit events')
|
|
170
168
|
.action(async (options, command) => {
|
|
171
169
|
await graphPull(options, command)
|
|
172
170
|
})
|
|
173
|
-
|
|
174
|
-
module.exports = { createGraphPullCommand }
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
import { createGraphConfigWriteCommand } from './graph-config-write.mjs'
|
|
3
|
+
import { createGraphEditCommand } from './graph-edit.mjs'
|
|
4
|
+
import { createGraphHandlerCommand } from './graph-handler.mjs'
|
|
5
|
+
import { createGraphInitCommand } from './graph-init.mjs'
|
|
6
|
+
import { createGraphLibraryCommand } from './graph-library.mjs'
|
|
7
|
+
import { createGraphOperationsCommand } from './graph-operations.mjs'
|
|
8
|
+
import { createGraphPullCommand } from './graph-pull.mjs'
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* The graph command
|
|
@@ -21,7 +21,7 @@ const graph = (options, command) => {
|
|
|
21
21
|
* @param {import('../base-command.mjs').default} program
|
|
22
22
|
* @returns
|
|
23
23
|
*/
|
|
24
|
-
const createGraphCommand = (program) => {
|
|
24
|
+
export const createGraphCommand = (program) => {
|
|
25
25
|
createGraphConfigWriteCommand(program)
|
|
26
26
|
createGraphEditCommand(program)
|
|
27
27
|
createGraphHandlerCommand(program)
|
|
@@ -36,5 +36,3 @@ const createGraphCommand = (program) => {
|
|
|
36
36
|
.addExamples(['netlify graph:pull', 'netlify graph:edit'])
|
|
37
37
|
.action(graph)
|
|
38
38
|
}
|
|
39
|
-
|
|
40
|
-
module.exports = { createGraphCommand }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createGraphCommand } from './graph.mjs'
|
|
@@ -3,12 +3,15 @@ import dotProp from 'dot-prop'
|
|
|
3
3
|
import inquirer from 'inquirer'
|
|
4
4
|
import isEmpty from 'lodash/isEmpty.js'
|
|
5
5
|
|
|
6
|
+
import getRepoData from '../../utils/get-repo-data.mjs'
|
|
7
|
+
import { ensureNetlifyIgnore } from '../../utils/gitignore.mjs'
|
|
6
8
|
import utils from '../../utils/index.cjs'
|
|
7
9
|
import { configureRepo } from '../../utils/init/config.cjs'
|
|
8
|
-
import {
|
|
10
|
+
import { track } from '../../utils/telemetry/index.mjs'
|
|
11
|
+
import { link } from '../link/index.mjs'
|
|
9
12
|
import { sitesCreate } from '../sites/index.mjs'
|
|
10
13
|
|
|
11
|
-
const { chalk,
|
|
14
|
+
const { chalk, exit, log } = utils
|
|
12
15
|
|
|
13
16
|
const persistState = ({ siteInfo, state }) => {
|
|
14
17
|
// Save to .netlify/state.json file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createLinkCommand, link } from './link.mjs'
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
|
|
3
|
-
const isEmpty = require('lodash/isEmpty')
|
|
2
|
+
import inquirer from 'inquirer'
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import { listSites } from '../../lib/api.mjs'
|
|
5
|
+
import getRepoData from '../../utils/get-repo-data.mjs'
|
|
6
|
+
import { ensureNetlifyIgnore } from '../../utils/gitignore.mjs'
|
|
7
|
+
import utils from '../../utils/index.cjs'
|
|
8
|
+
import { track } from '../../utils/telemetry/index.mjs'
|
|
9
|
+
|
|
10
|
+
const { chalk, error, exit, log } = utils
|
|
7
11
|
|
|
8
12
|
/**
|
|
9
13
|
*
|
|
10
|
-
* @param {import('../base-command').NetlifyOptions} netlify
|
|
14
|
+
* @param {import('../base-command.mjs').NetlifyOptions} netlify
|
|
11
15
|
* @param {import('commander').OptionValues} options
|
|
12
16
|
*/
|
|
13
17
|
const linkPrompt = async (netlify, options) => {
|
|
@@ -51,7 +55,7 @@ const linkPrompt = async (netlify, options) => {
|
|
|
51
55
|
log()
|
|
52
56
|
const sites = await listSites({ api, options: { filter: 'all' } })
|
|
53
57
|
|
|
54
|
-
if (
|
|
58
|
+
if (sites.length === 0) {
|
|
55
59
|
error(`You don't have any sites yet. Run ${chalk.cyanBright('netlify sites:create')} to create a site.`)
|
|
56
60
|
}
|
|
57
61
|
|
|
@@ -60,7 +64,7 @@ const linkPrompt = async (netlify, options) => {
|
|
|
60
64
|
)
|
|
61
65
|
|
|
62
66
|
// If no remote matches. Throw error
|
|
63
|
-
if (
|
|
67
|
+
if (matchingSites.length === 0) {
|
|
64
68
|
log(chalk.redBright.bold.underline(`No Matching Site Found`))
|
|
65
69
|
log()
|
|
66
70
|
log(`No site found with the remote ${repoData.httpsUrl}.
|
|
@@ -125,7 +129,7 @@ Run ${chalk.cyanBright('git remote -v')} to see a list of your git remotes.`)
|
|
|
125
129
|
}
|
|
126
130
|
}
|
|
127
131
|
|
|
128
|
-
if (
|
|
132
|
+
if (!matchingSites || matchingSites.length === 0) {
|
|
129
133
|
error(`No site names found containing '${searchTerm}'.
|
|
130
134
|
|
|
131
135
|
Run ${chalk.cyanBright('netlify link')} again to try a new search,
|
|
@@ -165,7 +169,7 @@ or run ${chalk.cyanBright('netlify sites:create')} to create a site.`)
|
|
|
165
169
|
error(error_)
|
|
166
170
|
}
|
|
167
171
|
|
|
168
|
-
if (
|
|
172
|
+
if (!sites || sites.length === 0) {
|
|
169
173
|
error(`You don't have any sites yet. Run ${chalk.cyanBright('netlify sites:create')} to create a site.`)
|
|
170
174
|
}
|
|
171
175
|
|
|
@@ -240,7 +244,7 @@ or run ${chalk.cyanBright('netlify sites:create')} to create a site.`)
|
|
|
240
244
|
* @param {import('commander').OptionValues} options
|
|
241
245
|
* @param {import('../base-command.mjs').default} command
|
|
242
246
|
*/
|
|
243
|
-
const link = async (options, command) => {
|
|
247
|
+
export const link = async (options, command) => {
|
|
244
248
|
await command.authenticate()
|
|
245
249
|
|
|
246
250
|
const {
|
|
@@ -337,7 +341,7 @@ const link = async (options, command) => {
|
|
|
337
341
|
* @param {import('../base-command.mjs').default} program
|
|
338
342
|
* @returns
|
|
339
343
|
*/
|
|
340
|
-
const createLinkCommand = (program) =>
|
|
344
|
+
export const createLinkCommand = (program) =>
|
|
341
345
|
program
|
|
342
346
|
.command('link')
|
|
343
347
|
.description('Link a local repo or project folder to an existing site on Netlify')
|
|
@@ -346,5 +350,3 @@ const createLinkCommand = (program) =>
|
|
|
346
350
|
.option('--gitRemoteName <name>', 'Name of Git remote to use. e.g. "origin"')
|
|
347
351
|
.addExamples(['netlify link', 'netlify link --id 123-123-123-123', 'netlify link --name my-site-name'])
|
|
348
352
|
.action(link)
|
|
349
|
-
|
|
350
|
-
module.exports = { createLinkCommand, link }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createLmCommand } from './lm.mjs'
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
|
|
2
|
+
import Listr from 'listr'
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
import {
|
|
5
5
|
checkGitLFSVersionStep,
|
|
6
6
|
checkGitVersionStep,
|
|
7
7
|
checkHelperVersionStep,
|
|
8
8
|
checkLFSFiltersStep,
|
|
9
|
-
}
|
|
9
|
+
} from '../../utils/lm/steps.mjs'
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* The lm:info command
|
|
@@ -36,7 +36,5 @@ const lmInfo = async () => {
|
|
|
36
36
|
* @param {import('../base-command.mjs').default} program
|
|
37
37
|
* @returns
|
|
38
38
|
*/
|
|
39
|
-
const createLmInfoCommand = (program) =>
|
|
39
|
+
export const createLmInfoCommand = (program) =>
|
|
40
40
|
program.command('lm:info').description('Show large media requirements information.').action(lmInfo)
|
|
41
|
-
|
|
42
|
-
module.exports = { createLmInfoCommand }
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { installPlatform } from '../../utils/lm/install.mjs'
|
|
3
|
+
import { printBanner } from '../../utils/lm/ui.mjs'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* The lm:install command
|
|
@@ -18,7 +18,7 @@ const lmInstall = async ({ force }) => {
|
|
|
18
18
|
* @param {import('../base-command.mjs').default} program
|
|
19
19
|
* @returns
|
|
20
20
|
*/
|
|
21
|
-
const createLmInstallCommand = (program) =>
|
|
21
|
+
export const createLmInstallCommand = (program) =>
|
|
22
22
|
program
|
|
23
23
|
.command('lm:install')
|
|
24
24
|
.alias('lm:init')
|
|
@@ -29,5 +29,3 @@ and configures your Git environment with the right credentials.`,
|
|
|
29
29
|
)
|
|
30
30
|
.option('-f, --force', 'Force the credentials helper installation')
|
|
31
31
|
.action(lmInstall)
|
|
32
|
-
|
|
33
|
-
module.exports = { createLmInstallCommand }
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
|
|
2
|
+
import Listr from 'listr'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
import utils from '../../utils/index.cjs'
|
|
5
|
+
import { installPlatform } from '../../utils/lm/install.mjs'
|
|
6
|
+
import { checkHelperVersion } from '../../utils/lm/requirements.mjs'
|
|
7
|
+
import { printBanner } from '../../utils/lm/ui.mjs'
|
|
8
|
+
|
|
9
|
+
const { error, execa } = utils
|
|
8
10
|
|
|
9
11
|
const installHelperIfMissing = async function ({ force }) {
|
|
10
12
|
let installHelper = false
|
|
@@ -94,7 +96,7 @@ const lmSetup = async (options, command) => {
|
|
|
94
96
|
* @param {import('../base-command.mjs').default} program
|
|
95
97
|
* @returns
|
|
96
98
|
*/
|
|
97
|
-
const createLmSetupCommand = (program) =>
|
|
99
|
+
export const createLmSetupCommand = (program) =>
|
|
98
100
|
program
|
|
99
101
|
.command('lm:setup')
|
|
100
102
|
.description('Configures your site to use Netlify Large Media')
|
|
@@ -102,5 +104,3 @@ const createLmSetupCommand = (program) =>
|
|
|
102
104
|
.option('-f, --force-install', 'Force the credentials helper installation')
|
|
103
105
|
.addHelpText('after', 'It runs the install command if you have not installed the dependencies yet.')
|
|
104
106
|
.action(lmSetup)
|
|
105
|
-
|
|
106
|
-
module.exports = { createLmSetupCommand }
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
|
|
2
|
+
import { uninstall } from '../../utils/lm/install.mjs'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The lm:uninstall command
|
|
@@ -13,7 +13,7 @@ const lmUninstall = async () => {
|
|
|
13
13
|
* @param {import('../base-command.mjs').default} program
|
|
14
14
|
* @returns
|
|
15
15
|
*/
|
|
16
|
-
const createLmUninstallCommand = (program) =>
|
|
16
|
+
export const createLmUninstallCommand = (program) =>
|
|
17
17
|
program
|
|
18
18
|
.command('lm:uninstall', { hidden: true })
|
|
19
19
|
.alias('lm:remove')
|
|
@@ -21,5 +21,3 @@ const createLmUninstallCommand = (program) =>
|
|
|
21
21
|
'Uninstalls Netlify git credentials helper and cleans up any related configuration changes made by the install command.',
|
|
22
22
|
)
|
|
23
23
|
.action(lmUninstall)
|
|
24
|
-
|
|
25
|
-
module.exports = { createLmUninstallCommand }
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { createLmInfoCommand } from './lm-info.mjs'
|
|
3
|
+
import { createLmInstallCommand } from './lm-install.mjs'
|
|
4
|
+
import { createLmSetupCommand } from './lm-setup.mjs'
|
|
5
|
+
import { createLmUninstallCommand } from './lm-uninstall.mjs'
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* The lm command
|
|
@@ -18,7 +18,7 @@ const lm = (options, command) => {
|
|
|
18
18
|
* @param {import('../base-command.mjs').default} program
|
|
19
19
|
* @returns
|
|
20
20
|
*/
|
|
21
|
-
const createLmCommand = (program) => {
|
|
21
|
+
export const createLmCommand = (program) => {
|
|
22
22
|
createLmInfoCommand(program)
|
|
23
23
|
createLmInstallCommand(program)
|
|
24
24
|
createLmSetupCommand(program)
|
|
@@ -30,5 +30,3 @@ const createLmCommand = (program) => {
|
|
|
30
30
|
.addExamples(['netlify lm:info', 'netlify lm:install', 'netlify lm:setup'])
|
|
31
31
|
.action(lm)
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
module.exports = { createLmCommand }
|
package/src/commands/main.mjs
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
import { readFile } from 'fs/promises'
|
|
3
2
|
import process from 'process'
|
|
4
|
-
import { fileURLToPath } from 'url'
|
|
5
3
|
|
|
6
4
|
import { Option } from 'commander'
|
|
7
5
|
import inquirer from 'inquirer'
|
|
8
6
|
import { findBestMatch } from 'string-similarity'
|
|
9
7
|
|
|
10
|
-
|
|
8
|
+
import getPackageJson from '../utils/get-package-json.mjs'
|
|
11
9
|
import utils from '../utils/index.cjs'
|
|
10
|
+
import { track } from '../utils/telemetry/index.mjs'
|
|
12
11
|
|
|
13
12
|
import { createAddonsCommand } from './addons/index.mjs'
|
|
14
13
|
import { createApiCommand } from './api/index.mjs'
|
|
@@ -16,24 +15,24 @@ import BaseCommand from './base-command.mjs'
|
|
|
16
15
|
import { createBuildCommand } from './build/index.mjs'
|
|
17
16
|
import { createCompletionCommand } from './completion/index.mjs'
|
|
18
17
|
import { createDeployCommand } from './deploy/index.mjs'
|
|
19
|
-
import { createDevCommand } from './dev/index.
|
|
20
|
-
import { createEnvCommand } from './env/index.
|
|
18
|
+
import { createDevCommand } from './dev/index.mjs'
|
|
19
|
+
import { createEnvCommand } from './env/index.mjs'
|
|
21
20
|
import { createFunctionsCommand } from './functions/index.mjs'
|
|
22
|
-
import { createGraphCommand } from './graph/index.
|
|
21
|
+
import { createGraphCommand } from './graph/index.mjs'
|
|
23
22
|
import { createInitCommand } from './init/index.mjs'
|
|
24
|
-
import { createLinkCommand } from './link/index.
|
|
25
|
-
import { createLmCommand } from './lm/index.
|
|
23
|
+
import { createLinkCommand } from './link/index.mjs'
|
|
24
|
+
import { createLmCommand } from './lm/index.mjs'
|
|
26
25
|
import { createLoginCommand } from './login/index.mjs'
|
|
27
26
|
import { createLogoutCommand } from './logout/index.mjs'
|
|
28
27
|
import { createOpenCommand } from './open/index.mjs'
|
|
29
|
-
import { createRecipesCommand
|
|
28
|
+
import { createRecipesCommand } from './recipes/index.mjs'
|
|
30
29
|
import { createSitesCommand } from './sites/index.mjs'
|
|
31
30
|
import { createStatusCommand } from './status/index.mjs'
|
|
32
31
|
import { createSwitchCommand } from './switch/index.mjs'
|
|
33
32
|
import { createUnlinkCommand } from './unlink/index.mjs'
|
|
34
33
|
import { createWatchCommand } from './watch/index.mjs'
|
|
35
34
|
|
|
36
|
-
const { BANG, NETLIFY_CYAN, USER_AGENT, chalk, error, execa, exit, getGlobalConfig, log,
|
|
35
|
+
const { BANG, NETLIFY_CYAN, USER_AGENT, chalk, error, execa, exit, getGlobalConfig, log, warn } = utils
|
|
37
36
|
|
|
38
37
|
const SUGGESTION_TIMEOUT = 1e4
|
|
39
38
|
|
|
@@ -90,7 +89,7 @@ const mainCommand = async function (options, command) {
|
|
|
90
89
|
|
|
91
90
|
// if no command show the header and the help
|
|
92
91
|
if (command.args.length === 0) {
|
|
93
|
-
const pkg =
|
|
92
|
+
const pkg = await getPackageJson()
|
|
94
93
|
|
|
95
94
|
const title = `${chalk.bgBlack.cyan('⬥ Netlify CLI')}`
|
|
96
95
|
const docsMsg = `${chalk.greenBright('Read the docs:')} https://docs.netlify.com/cli/get-started/`
|
|
@@ -167,7 +166,6 @@ export const createMainCommand = () => {
|
|
|
167
166
|
createEnvCommand(program)
|
|
168
167
|
createFunctionsCommand(program)
|
|
169
168
|
createRecipesCommand(program)
|
|
170
|
-
createRecipesListCommand(program)
|
|
171
169
|
createGraphCommand(program)
|
|
172
170
|
createInitCommand(program)
|
|
173
171
|
createLinkCommand(program)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import fs from 'fs/promises'
|
|
2
|
+
import { dirname, join, resolve } from 'path'
|
|
3
|
+
import { fileURLToPath, pathToFileURL } from 'url'
|
|
4
|
+
|
|
5
|
+
const directoryPath = dirname(fileURLToPath(import.meta.url))
|
|
6
|
+
|
|
7
|
+
export const getRecipe = async (name) => {
|
|
8
|
+
const recipePath = resolve(directoryPath, '../../recipes', name, 'index.mjs')
|
|
9
|
+
|
|
10
|
+
// windows needs a URL for absolute paths
|
|
11
|
+
// eslint-disable-next-line import/no-dynamic-require
|
|
12
|
+
const recipe = await import(pathToFileURL(recipePath).href)
|
|
13
|
+
|
|
14
|
+
return recipe
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const listRecipes = async () => {
|
|
18
|
+
const recipesPath = resolve(directoryPath, '../../recipes')
|
|
19
|
+
const recipeNames = await fs.readdir(recipesPath)
|
|
20
|
+
const recipes = await Promise.all(
|
|
21
|
+
recipeNames.map(async (name) => {
|
|
22
|
+
const recipePath = join(recipesPath, name, 'index.mjs')
|
|
23
|
+
|
|
24
|
+
// windows needs a URL for absolute paths
|
|
25
|
+
// eslint-disable-next-line import/no-dynamic-require
|
|
26
|
+
const recipe = await import(pathToFileURL(recipePath).href)
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
...recipe,
|
|
30
|
+
name,
|
|
31
|
+
}
|
|
32
|
+
}),
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
return recipes
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createRecipesCommand, runRecipe } from './recipes.mjs'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
|
|
2
|
+
import AsciiTable from 'ascii-table'
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
import { listRecipes } from './common.mjs'
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* The recipes:list command
|
|
@@ -24,11 +24,9 @@ const recipesListCommand = async () => {
|
|
|
24
24
|
* @param {import('../base-command.mjs').default} program
|
|
25
25
|
* @returns
|
|
26
26
|
*/
|
|
27
|
-
const createRecipesListCommand = (program) =>
|
|
27
|
+
export const createRecipesListCommand = (program) =>
|
|
28
28
|
program
|
|
29
29
|
.command('recipes:list')
|
|
30
30
|
.description(`(Beta) List the recipes available to create and modify files in a project`)
|
|
31
31
|
.addExamples(['netlify recipes:list'])
|
|
32
32
|
.action(recipesListCommand)
|
|
33
|
-
|
|
34
|
-
module.exports = { createRecipesListCommand }
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
|
|
2
|
+
import { basename } from 'path'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
import inquirer from 'inquirer'
|
|
5
|
+
import { findBestMatch } from 'string-similarity'
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
import utils from '../../utils/command-helpers.cjs'
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
import { getRecipe, listRecipes } from './common.mjs'
|
|
10
|
+
import { createRecipesListCommand } from './recipes-list.mjs'
|
|
10
11
|
|
|
11
12
|
const SUGGESTION_TIMEOUT = 1e4
|
|
12
13
|
|
|
@@ -62,8 +63,8 @@ const recipesCommand = async (recipeName, options, command) => {
|
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
65
|
|
|
65
|
-
const runRecipe = ({ config, recipeName, repositoryRoot }) => {
|
|
66
|
-
const recipe = getRecipe(recipeName)
|
|
66
|
+
export const runRecipe = async ({ config, recipeName, repositoryRoot }) => {
|
|
67
|
+
const recipe = await getRecipe(recipeName)
|
|
67
68
|
|
|
68
69
|
return recipe.run({ config, repositoryRoot })
|
|
69
70
|
}
|
|
@@ -73,7 +74,9 @@ const runRecipe = ({ config, recipeName, repositoryRoot }) => {
|
|
|
73
74
|
* @param {import('../base-command.mjs').default} program
|
|
74
75
|
* @returns
|
|
75
76
|
*/
|
|
76
|
-
const createRecipesCommand = (program) =>
|
|
77
|
+
export const createRecipesCommand = (program) => {
|
|
78
|
+
createRecipesListCommand(program)
|
|
79
|
+
|
|
77
80
|
program
|
|
78
81
|
.command('recipes')
|
|
79
82
|
.argument('[name]', 'name of the recipe')
|
|
@@ -81,5 +84,4 @@ const createRecipesCommand = (program) =>
|
|
|
81
84
|
.option('-n, --name <name>', 'recipe name to use')
|
|
82
85
|
.addExamples(['netlify recipes my-recipe', 'netlify recipes --name my-recipe'])
|
|
83
86
|
.action(recipesCommand)
|
|
84
|
-
|
|
85
|
-
module.exports = { createRecipesCommand, runRecipe }
|
|
87
|
+
}
|
|
@@ -5,14 +5,16 @@ import pick from 'lodash/pick.js'
|
|
|
5
5
|
import parseGitHubUrl from 'parse-github-url'
|
|
6
6
|
import prettyjson from 'prettyjson'
|
|
7
7
|
|
|
8
|
+
import getRepoData from '../../utils/get-repo-data.mjs'
|
|
8
9
|
import utils from '../../utils/index.cjs'
|
|
9
10
|
import { getGitHubToken } from '../../utils/init/config-github.cjs'
|
|
10
11
|
import { configureRepo } from '../../utils/init/config.cjs'
|
|
11
12
|
import { createRepo, getTemplatesFromGitHub, validateTemplate } from '../../utils/sites/utils.cjs'
|
|
13
|
+
import { track } from '../../utils/telemetry/index.mjs'
|
|
12
14
|
|
|
13
15
|
import { getSiteNameInput } from './sites-create.mjs'
|
|
14
16
|
|
|
15
|
-
const { chalk, error, execa,
|
|
17
|
+
const { chalk, error, execa, getTerminalLink, log, logJson, warn } = utils
|
|
16
18
|
|
|
17
19
|
export const fetchTemplates = async (token) => {
|
|
18
20
|
const templatesFromGithubOrg = await getTemplatesFromGitHub(token)
|