netlify-cli 9.10.0 → 9.12.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/npm-shrinkwrap.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "netlify-cli",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.12.1",
|
|
4
4
|
"lockfileVersion": 2,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "netlify-cli",
|
|
9
|
-
"version": "9.
|
|
9
|
+
"version": "9.12.1",
|
|
10
10
|
"hasInstallScript": true,
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@netlify/build": "^26.3.
|
|
14
|
-
"@netlify/config": "^17.0.
|
|
13
|
+
"@netlify/build": "^26.3.13",
|
|
14
|
+
"@netlify/config": "^17.0.17",
|
|
15
15
|
"@netlify/framework-info": "^9.0.2",
|
|
16
16
|
"@netlify/local-functions-proxy": "^1.1.1",
|
|
17
17
|
"@netlify/plugin-edge-handlers": "^3.0.7",
|
|
@@ -2358,9 +2358,9 @@
|
|
|
2358
2358
|
}
|
|
2359
2359
|
},
|
|
2360
2360
|
"node_modules/@netlify/build": {
|
|
2361
|
-
"version": "26.3.
|
|
2362
|
-
"resolved": "https://registry.npmjs.org/@netlify/build/-/build-26.3.
|
|
2363
|
-
"integrity": "sha512-
|
|
2361
|
+
"version": "26.3.13",
|
|
2362
|
+
"resolved": "https://registry.npmjs.org/@netlify/build/-/build-26.3.13.tgz",
|
|
2363
|
+
"integrity": "sha512-FoG4snU2BwCy85Uk6DA3/ewkKE6YrG9jEAs6t6hKe0kfJyTxxyOqThoFzYVK3/9Zm2uZKV4wWQ0Jq7TlXiHajA==",
|
|
2364
2364
|
"dependencies": {
|
|
2365
2365
|
"@bugsnag/js": "^7.0.0",
|
|
2366
2366
|
"@netlify/cache-utils": "^4.0.0",
|
|
@@ -2368,7 +2368,7 @@
|
|
|
2368
2368
|
"@netlify/functions-utils": "^4.0.0",
|
|
2369
2369
|
"@netlify/git-utils": "^4.0.0",
|
|
2370
2370
|
"@netlify/plugin-edge-handlers": "^3.0.7",
|
|
2371
|
-
"@netlify/plugins-list": "^6.
|
|
2371
|
+
"@netlify/plugins-list": "^6.15.0",
|
|
2372
2372
|
"@netlify/run-utils": "^4.0.0",
|
|
2373
2373
|
"@netlify/zip-it-and-ship-it": "5.9.0",
|
|
2374
2374
|
"@sindresorhus/slugify": "^2.0.0",
|
|
@@ -3110,9 +3110,9 @@
|
|
|
3110
3110
|
}
|
|
3111
3111
|
},
|
|
3112
3112
|
"node_modules/@netlify/config": {
|
|
3113
|
-
"version": "17.0.
|
|
3114
|
-
"resolved": "https://registry.npmjs.org/@netlify/config/-/config-17.0.
|
|
3115
|
-
"integrity": "sha512-
|
|
3113
|
+
"version": "17.0.17",
|
|
3114
|
+
"resolved": "https://registry.npmjs.org/@netlify/config/-/config-17.0.17.tgz",
|
|
3115
|
+
"integrity": "sha512-D1qBygGjsEoskqNxhWiXD2ukvd/KKpjC2UYF6V8n5Z8FCu11nbfS96I+yK2rWrfPV34Qj3cwKKrntDzQiDcphQ==",
|
|
3116
3116
|
"dependencies": {
|
|
3117
3117
|
"chalk": "^5.0.0",
|
|
3118
3118
|
"cron-parser": "^4.1.0",
|
|
@@ -26118,9 +26118,9 @@
|
|
|
26118
26118
|
}
|
|
26119
26119
|
},
|
|
26120
26120
|
"@netlify/build": {
|
|
26121
|
-
"version": "26.3.
|
|
26122
|
-
"resolved": "https://registry.npmjs.org/@netlify/build/-/build-26.3.
|
|
26123
|
-
"integrity": "sha512-
|
|
26121
|
+
"version": "26.3.13",
|
|
26122
|
+
"resolved": "https://registry.npmjs.org/@netlify/build/-/build-26.3.13.tgz",
|
|
26123
|
+
"integrity": "sha512-FoG4snU2BwCy85Uk6DA3/ewkKE6YrG9jEAs6t6hKe0kfJyTxxyOqThoFzYVK3/9Zm2uZKV4wWQ0Jq7TlXiHajA==",
|
|
26124
26124
|
"requires": {
|
|
26125
26125
|
"@bugsnag/js": "^7.0.0",
|
|
26126
26126
|
"@netlify/cache-utils": "^4.0.0",
|
|
@@ -26128,7 +26128,7 @@
|
|
|
26128
26128
|
"@netlify/functions-utils": "^4.0.0",
|
|
26129
26129
|
"@netlify/git-utils": "^4.0.0",
|
|
26130
26130
|
"@netlify/plugin-edge-handlers": "^3.0.7",
|
|
26131
|
-
"@netlify/plugins-list": "^6.
|
|
26131
|
+
"@netlify/plugins-list": "^6.15.0",
|
|
26132
26132
|
"@netlify/run-utils": "^4.0.0",
|
|
26133
26133
|
"@netlify/zip-it-and-ship-it": "5.9.0",
|
|
26134
26134
|
"@sindresorhus/slugify": "^2.0.0",
|
|
@@ -26583,9 +26583,9 @@
|
|
|
26583
26583
|
}
|
|
26584
26584
|
},
|
|
26585
26585
|
"@netlify/config": {
|
|
26586
|
-
"version": "17.0.
|
|
26587
|
-
"resolved": "https://registry.npmjs.org/@netlify/config/-/config-17.0.
|
|
26588
|
-
"integrity": "sha512-
|
|
26586
|
+
"version": "17.0.17",
|
|
26587
|
+
"resolved": "https://registry.npmjs.org/@netlify/config/-/config-17.0.17.tgz",
|
|
26588
|
+
"integrity": "sha512-D1qBygGjsEoskqNxhWiXD2ukvd/KKpjC2UYF6V8n5Z8FCu11nbfS96I+yK2rWrfPV34Qj3cwKKrntDzQiDcphQ==",
|
|
26589
26589
|
"requires": {
|
|
26590
26590
|
"chalk": "^5.0.0",
|
|
26591
26591
|
"cron-parser": "^4.1.0",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "netlify-cli",
|
|
3
3
|
"description": "Netlify command line tool",
|
|
4
|
-
"version": "9.
|
|
4
|
+
"version": "9.12.1",
|
|
5
5
|
"author": "Netlify Inc.",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Abraham Schilling <AbrahamSchilling@gmail.com> (https://gitlab.com/n4bb12)",
|
|
@@ -200,8 +200,8 @@
|
|
|
200
200
|
"prettier": "--ignore-path .gitignore --loglevel=warn \"{src,tools,scripts,site,tests,.github}/**/*.{mjs,cjs,js,md,yml,json,html}\" \"*.{mjs,cjs,js,yml,json,html}\" \".*.{mjs,cjs,js,yml,json,html}\" \"!CHANGELOG.md\" \"!npm-shrinkwrap.json\" \"!site/package-lock.json\" \"!.github/**/*.md\""
|
|
201
201
|
},
|
|
202
202
|
"dependencies": {
|
|
203
|
-
"@netlify/build": "^26.3.
|
|
204
|
-
"@netlify/config": "^17.0.
|
|
203
|
+
"@netlify/build": "^26.3.13",
|
|
204
|
+
"@netlify/config": "^17.0.17",
|
|
205
205
|
"@netlify/framework-info": "^9.0.2",
|
|
206
206
|
"@netlify/local-functions-proxy": "^1.1.1",
|
|
207
207
|
"@netlify/plugin-edge-handlers": "^3.0.7",
|
package/src/commands/dev/dev.js
CHANGED
|
@@ -348,7 +348,7 @@ const dev = async (options, command) => {
|
|
|
348
348
|
exit(1)
|
|
349
349
|
}
|
|
350
350
|
|
|
351
|
-
command.setAnalyticsPayload({ projectType: settings.framework || 'custom', live: options.live })
|
|
351
|
+
command.setAnalyticsPayload({ projectType: settings.framework || 'custom', live: options.live, graph: options.graph })
|
|
352
352
|
|
|
353
353
|
const startNetlifyGraphWatcher = Boolean(options.graph)
|
|
354
354
|
if (startNetlifyGraphWatcher) {
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
const inquirer = require('inquirer')
|
|
4
4
|
const pick = require('lodash/pick')
|
|
5
|
+
const parseGitHubUrl = require('parse-github-url')
|
|
5
6
|
const prettyjson = require('prettyjson')
|
|
7
|
+
const terminalLink = require('terminal-link')
|
|
6
8
|
|
|
7
9
|
const { chalk, error, getRepoData, log, logJson, track, warn } = require('../../utils')
|
|
8
10
|
const { configureRepo } = require('../../utils/init/config')
|
|
9
11
|
const { getGitHubToken } = require('../../utils/init/config-github')
|
|
10
|
-
const { createRepo, getTemplatesFromGitHub } = require('../../utils/sites/utils')
|
|
12
|
+
const { createRepo, getTemplatesFromGitHub, validateTemplate } = require('../../utils/sites/utils')
|
|
11
13
|
|
|
12
14
|
const { getSiteNameInput } = require('./sites-create')
|
|
13
15
|
|
|
@@ -23,12 +25,45 @@ const fetchTemplates = async (token) => {
|
|
|
23
25
|
}))
|
|
24
26
|
}
|
|
25
27
|
|
|
28
|
+
const getTemplateName = async ({ ghToken, options, repository }) => {
|
|
29
|
+
if (repository) {
|
|
30
|
+
const { repo } = parseGitHubUrl(repository)
|
|
31
|
+
return repo || `netlify-templates/${repository}`
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (options.url) {
|
|
35
|
+
const urlFromOptions = new URL(options.url)
|
|
36
|
+
return urlFromOptions.pathname.slice(1)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const templates = await fetchTemplates(ghToken)
|
|
40
|
+
|
|
41
|
+
log(`Choose one of our starter templates. Netlify will create a new repo for this template in your GitHub account.`)
|
|
42
|
+
|
|
43
|
+
const { templateName } = await inquirer.prompt([
|
|
44
|
+
{
|
|
45
|
+
type: 'list',
|
|
46
|
+
name: 'templateName',
|
|
47
|
+
message: 'Template:',
|
|
48
|
+
choices: templates.map((template) => ({
|
|
49
|
+
value: template.slug,
|
|
50
|
+
name: template.name,
|
|
51
|
+
})),
|
|
52
|
+
},
|
|
53
|
+
])
|
|
54
|
+
|
|
55
|
+
return templateName
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const getGitHubLink = ({ options, templateName }) => options.url || `https://github.com/${templateName}`
|
|
59
|
+
|
|
26
60
|
/**
|
|
27
61
|
* The sites:create-template command
|
|
62
|
+
* @param repository {string}
|
|
28
63
|
* @param {import('commander').OptionValues} options
|
|
29
64
|
* @param {import('../base-command').BaseCommand} command
|
|
30
65
|
*/
|
|
31
|
-
const sitesCreateTemplate = async (options, command) => {
|
|
66
|
+
const sitesCreateTemplate = async (repository, options, command) => {
|
|
32
67
|
const { api } = command.netlify
|
|
33
68
|
|
|
34
69
|
await command.authenticate()
|
|
@@ -36,27 +71,22 @@ const sitesCreateTemplate = async (options, command) => {
|
|
|
36
71
|
const { globalConfig } = command.netlify
|
|
37
72
|
const ghToken = await getGitHubToken({ globalConfig })
|
|
38
73
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
value: template.slug,
|
|
56
|
-
name: template.name,
|
|
57
|
-
})),
|
|
58
|
-
},
|
|
59
|
-
])
|
|
74
|
+
const templateName = await getTemplateName({ ghToken, options, repository })
|
|
75
|
+
const { exists, isTemplate } = await validateTemplate({ templateName, ghToken })
|
|
76
|
+
if (!exists) {
|
|
77
|
+
const githubLink = getGitHubLink({ options, templateName })
|
|
78
|
+
error(
|
|
79
|
+
`Could not find template ${chalk.bold(templateName)}. Please verify it exists and you can ${terminalLink(
|
|
80
|
+
'access to it on GitHub',
|
|
81
|
+
githubLink,
|
|
82
|
+
)}`,
|
|
83
|
+
)
|
|
84
|
+
return
|
|
85
|
+
}
|
|
86
|
+
if (!isTemplate) {
|
|
87
|
+
const githubLink = getGitHubLink({ options, templateName })
|
|
88
|
+
error(`${terminalLink(chalk.bold(templateName), githubLink)} is not a valid GitHub template`)
|
|
89
|
+
return
|
|
60
90
|
}
|
|
61
91
|
|
|
62
92
|
const accounts = await api.listAccountsForUser()
|
|
@@ -90,12 +120,12 @@ const sitesCreateTemplate = async (options, command) => {
|
|
|
90
120
|
const siteName = inputName ? inputName.trim() : siteSuggestion
|
|
91
121
|
|
|
92
122
|
// Create new repo from template
|
|
93
|
-
const repoResp = await createRepo(
|
|
123
|
+
const repoResp = await createRepo(templateName, ghToken, siteName)
|
|
94
124
|
|
|
95
125
|
if (repoResp.errors) {
|
|
96
126
|
if (repoResp.errors[0].includes('Name already exists on this account')) {
|
|
97
127
|
warn(
|
|
98
|
-
`Oh no! We found already a repository with this name. It seems you have already created a template with the name ${
|
|
128
|
+
`Oh no! We found already a repository with this name. It seems you have already created a template with the name ${templateName}. Please try to run the command again and provide a different name.`,
|
|
99
129
|
)
|
|
100
130
|
await inputSiteName()
|
|
101
131
|
} else {
|
|
@@ -206,7 +236,13 @@ Create a site from a starter template.`,
|
|
|
206
236
|
.option('-u, --url [url]', 'template url')
|
|
207
237
|
.option('-a, --account-slug [slug]', 'account slug to create the site under')
|
|
208
238
|
.option('-c, --with-ci', 'initialize CI hooks during site creation')
|
|
239
|
+
.argument('[repository]', 'repository to use as starter template')
|
|
209
240
|
.addHelpText('after', `(Beta) Create a site from starter template.`)
|
|
241
|
+
.addExamples([
|
|
242
|
+
'netlify sites:create-template',
|
|
243
|
+
'netlify sites:create-template nextjs-blog-theme',
|
|
244
|
+
'netlify sites:create-template my-github-profile/my-template',
|
|
245
|
+
])
|
|
210
246
|
.action(sitesCreateTemplate)
|
|
211
247
|
|
|
212
248
|
module.exports = { createSitesFromTemplateCommand, fetchTemplates }
|
|
@@ -120,7 +120,8 @@ const createHandler = function (options) {
|
|
|
120
120
|
if (func.isBackground) {
|
|
121
121
|
handleBackgroundFunction(functionName, response)
|
|
122
122
|
|
|
123
|
-
|
|
123
|
+
// background functions do not receive a clientContext
|
|
124
|
+
const { error } = await func.invoke(event)
|
|
124
125
|
|
|
125
126
|
handleBackgroundFunctionResult(functionName, error)
|
|
126
127
|
} else if (await func.isScheduled()) {
|
package/src/utils/sites/utils.js
CHANGED
|
@@ -12,8 +12,27 @@ const getTemplatesFromGitHub = async (token) => {
|
|
|
12
12
|
return allTemplates
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
const
|
|
16
|
-
const
|
|
15
|
+
const validateTemplate = async ({ ghToken, templateName }) => {
|
|
16
|
+
const response = await fetch(`https://api.github.com/repos/${templateName}`, {
|
|
17
|
+
headers: {
|
|
18
|
+
Authorization: `token ${ghToken}`,
|
|
19
|
+
},
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
if (response.status === 404) {
|
|
23
|
+
return { exists: false }
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (!response.ok) {
|
|
27
|
+
throw new Error(`Error fetching template ${templateName}: ${await response.text()}`)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const data = await response.json()
|
|
31
|
+
return { exists: true, isTemplate: data.is_template }
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const createRepo = async (templateName, ghToken, siteName) => {
|
|
35
|
+
const resp = await fetch(`https://api.github.com/repos/${templateName}/generate`, {
|
|
17
36
|
method: 'POST',
|
|
18
37
|
headers: {
|
|
19
38
|
Authorization: `token ${ghToken}`,
|
|
@@ -27,4 +46,4 @@ const createRepo = async (templateUrl, ghToken, siteName) => {
|
|
|
27
46
|
return data
|
|
28
47
|
}
|
|
29
48
|
|
|
30
|
-
module.exports = { getTemplatesFromGitHub, createRepo }
|
|
49
|
+
module.exports = { getTemplatesFromGitHub, createRepo, validateTemplate }
|