netlify-cli 17.38.0 → 17.38.1-rc-ds
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.js +2 -2
- package/dist/commands/base-command.d.ts.map +1 -1
- package/dist/commands/base-command.js +3 -2
- package/dist/commands/completion/completion.d.ts.map +1 -1
- package/dist/commands/completion/completion.js +7 -0
- package/dist/commands/deploy/deploy.js +2 -2
- package/dist/commands/main.d.ts +0 -4
- package/dist/commands/main.d.ts.map +1 -1
- package/dist/commands/main.js +1 -6
- package/dist/commands/sites/sites-create-template.d.ts.map +1 -1
- package/dist/commands/sites/sites-create-template.js +3 -4
- package/dist/commands/sites/sites-create.d.ts.map +1 -1
- package/dist/commands/sites/sites-create.js +1 -2
- package/dist/commands/status/status.d.ts.map +1 -1
- package/dist/commands/status/status.js +2 -6
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/addons/prepare.d.ts +0 -21
- package/dist/utils/addons/prepare.d.ts.map +1 -1
- package/dist/utils/addons/prepare.js +1 -85
- package/dist/utils/framework-server.js +1 -1
- package/dist/utils/headers.js +1 -1
- package/dist/utils/redirects.js +1 -1
- package/dist/utils/run-build.d.ts.map +1 -1
- package/dist/utils/run-build.js +6 -1
- package/dist/utils/types.d.ts +5 -11
- package/dist/utils/types.d.ts.map +1 -1
- package/functions-templates/javascript/scheduled-function/package.json +1 -1
- package/functions-templates/typescript/hello-world/package-lock.json +22 -22
- package/functions-templates/typescript/hello-world/package.json +1 -1
- package/functions-templates/typescript/scheduled-function/package.json +1 -1
- package/npm-shrinkwrap.json +872 -933
- package/package.json +13 -16
- package/dist/commands/addons/addons-auth.d.ts +0 -4
- package/dist/commands/addons/addons-auth.d.ts.map +0 -1
- package/dist/commands/addons/addons-auth.js +0 -22
- package/dist/commands/addons/addons-config.d.ts +0 -4
- package/dist/commands/addons/addons-config.d.ts.map +0 -1
- package/dist/commands/addons/addons-config.js +0 -144
- package/dist/commands/addons/addons-create.d.ts +0 -4
- package/dist/commands/addons/addons-create.d.ts.map +0 -1
- package/dist/commands/addons/addons-create.js +0 -89
- package/dist/commands/addons/addons-delete.d.ts +0 -4
- package/dist/commands/addons/addons-delete.d.ts.map +0 -1
- package/dist/commands/addons/addons-delete.js +0 -32
- package/dist/commands/addons/addons-list.d.ts +0 -4
- package/dist/commands/addons/addons-list.d.ts.map +0 -1
- package/dist/commands/addons/addons-list.js +0 -33
- package/dist/commands/addons/addons.d.ts +0 -3
- package/dist/commands/addons/addons.d.ts.map +0 -1
- package/dist/commands/addons/addons.js +0 -67
- package/dist/commands/addons/index.d.ts +0 -2
- package/dist/commands/addons/index.d.ts.map +0 -1
- package/dist/commands/addons/index.js +0 -1
- package/dist/commands/lm/index.d.ts +0 -2
- package/dist/commands/lm/index.d.ts.map +0 -1
- package/dist/commands/lm/index.js +0 -1
- package/dist/commands/lm/lm-info.d.ts +0 -5
- package/dist/commands/lm/lm-info.d.ts.map +0 -1
- package/dist/commands/lm/lm-info.js +0 -25
- package/dist/commands/lm/lm-install.d.ts +0 -3
- package/dist/commands/lm/lm-install.d.ts.map +0 -1
- package/dist/commands/lm/lm-install.js +0 -8
- package/dist/commands/lm/lm-setup.d.ts +0 -4
- package/dist/commands/lm/lm-setup.d.ts.map +0 -1
- package/dist/commands/lm/lm-setup.js +0 -79
- package/dist/commands/lm/lm-uninstall.d.ts +0 -5
- package/dist/commands/lm/lm-uninstall.d.ts.map +0 -1
- package/dist/commands/lm/lm-uninstall.js +0 -7
- package/dist/commands/lm/lm.d.ts +0 -3
- package/dist/commands/lm/lm.d.ts.map +0 -1
- package/dist/commands/lm/lm.js +0 -46
- package/dist/utils/addons/render.d.ts +0 -3
- package/dist/utils/addons/render.d.ts.map +0 -1
- package/dist/utils/addons/render.js +0 -36
- package/dist/utils/lm/install.d.ts +0 -11
- package/dist/utils/lm/install.d.ts.map +0 -1
- package/dist/utils/lm/install.js +0 -248
- package/dist/utils/lm/requirements.d.ts +0 -5
- package/dist/utils/lm/requirements.d.ts.map +0 -1
- package/dist/utils/lm/requirements.js +0 -56
- package/dist/utils/lm/steps.d.ts +0 -17
- package/dist/utils/lm/steps.d.ts.map +0 -1
- package/dist/utils/lm/steps.js +0 -35
- package/dist/utils/lm/ui.d.ts +0 -5
- package/dist/utils/lm/ui.d.ts.map +0 -1
- package/dist/utils/lm/ui.js +0 -17
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { Listr } from 'listr2';
|
|
2
|
-
import { error } from '../../utils/command-helpers.js';
|
|
3
|
-
import execa from '../../utils/execa.js';
|
|
4
|
-
import { installPlatform } from '../../utils/lm/install.js';
|
|
5
|
-
import { checkHelperVersion } from '../../utils/lm/requirements.js';
|
|
6
|
-
import { printBanner } from '../../utils/lm/ui.js';
|
|
7
|
-
// @ts-expect-error TS(7031) FIXME: Binding element 'force' implicitly has an 'any' ty... Remove this comment to see the full error message
|
|
8
|
-
const installHelperIfMissing = async function ({ force }) {
|
|
9
|
-
let installHelper = false;
|
|
10
|
-
try {
|
|
11
|
-
const version = await checkHelperVersion();
|
|
12
|
-
if (!version) {
|
|
13
|
-
installHelper = true;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
catch {
|
|
17
|
-
installHelper = true;
|
|
18
|
-
}
|
|
19
|
-
if (installHelper) {
|
|
20
|
-
return installPlatform({ force });
|
|
21
|
-
}
|
|
22
|
-
return false;
|
|
23
|
-
};
|
|
24
|
-
// @ts-expect-error TS(7006) FIXME: Parameter 'siteId' implicitly has an 'any' type.
|
|
25
|
-
const provisionService = async function (siteId, api) {
|
|
26
|
-
const addonName = 'large-media';
|
|
27
|
-
if (!siteId) {
|
|
28
|
-
throw new Error('No site id found, please run inside a site folder or `netlify link`');
|
|
29
|
-
}
|
|
30
|
-
try {
|
|
31
|
-
await api.createServiceInstance({
|
|
32
|
-
siteId,
|
|
33
|
-
addon: addonName,
|
|
34
|
-
body: {},
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
catch (error_) {
|
|
38
|
-
// error is JSONHTTPError
|
|
39
|
-
// @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
|
|
40
|
-
throw new Error(error_.json.error);
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
// @ts-expect-error TS(7006) FIXME: Parameter 'siteId' implicitly has an 'any' type.
|
|
44
|
-
const configureLFSURL = async function (siteId, api) {
|
|
45
|
-
const siteInfo = await api.getSite({ siteId });
|
|
46
|
-
const url = `https://${siteInfo.id_domain}/.netlify/large-media`;
|
|
47
|
-
return execa('git', ['config', '-f', '.lfsconfig', 'lfs.url', url]);
|
|
48
|
-
};
|
|
49
|
-
export const lmSetup = async (options, command) => {
|
|
50
|
-
await command.authenticate();
|
|
51
|
-
const { api, site } = command.netlify;
|
|
52
|
-
let helperInstalled = false;
|
|
53
|
-
if (!options.skipInstall) {
|
|
54
|
-
try {
|
|
55
|
-
helperInstalled = await installHelperIfMissing({ force: options.forceInstall });
|
|
56
|
-
}
|
|
57
|
-
catch (error_) {
|
|
58
|
-
error(error_);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
const tasks = new Listr([
|
|
62
|
-
{
|
|
63
|
-
title: 'Provisioning Netlify Large Media',
|
|
64
|
-
async task() {
|
|
65
|
-
await provisionService(site.id, api);
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
title: 'Configuring Git LFS for this site',
|
|
70
|
-
async task() {
|
|
71
|
-
await configureLFSURL(site.id, api);
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
]);
|
|
75
|
-
await tasks.run().catch(() => { });
|
|
76
|
-
if (helperInstalled) {
|
|
77
|
-
printBanner(options.forceInstall);
|
|
78
|
-
}
|
|
79
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lm-uninstall.d.ts","sourceRoot":"","sources":["../../../src/commands/lm/lm-uninstall.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,WAAW,qBAEvB,CAAA"}
|
package/dist/commands/lm/lm.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lm.d.ts","sourceRoot":"","sources":["../../../src/commands/lm/lm.ts"],"names":[],"mappings":"AAEA,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAM5C,eAAO,MAAM,eAAe,YAAa,WAAW,SAoDnD,CAAA"}
|
package/dist/commands/lm/lm.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
const lm = (options, command) => {
|
|
2
|
-
command.help();
|
|
3
|
-
};
|
|
4
|
-
export const createLmCommand = (program) => {
|
|
5
|
-
program
|
|
6
|
-
.command('lm:info', { hidden: true })
|
|
7
|
-
.description('Show large media requirements information.')
|
|
8
|
-
.action(async () => {
|
|
9
|
-
const { lmInfo } = await import('./lm-info.js');
|
|
10
|
-
await lmInfo();
|
|
11
|
-
});
|
|
12
|
-
program
|
|
13
|
-
.command('lm:install', { hidden: true })
|
|
14
|
-
.alias('lm:init')
|
|
15
|
-
.description(`Configures your computer to use Netlify Large Media
|
|
16
|
-
It installs the required credentials helper for Git,
|
|
17
|
-
and configures your Git environment with the right credentials.`)
|
|
18
|
-
.option('-f, --force', 'Force the credentials helper installation')
|
|
19
|
-
.action(async (options) => {
|
|
20
|
-
const { lmInstall } = await import('./lm-install.js');
|
|
21
|
-
await lmInstall(options);
|
|
22
|
-
});
|
|
23
|
-
program
|
|
24
|
-
.command('lm:setup', { hidden: true })
|
|
25
|
-
.description('Configures your site to use Netlify Large Media')
|
|
26
|
-
.option('-s, --skip-install', 'Skip the credentials helper installation check')
|
|
27
|
-
.option('-f, --force-install', 'Force the credentials helper installation')
|
|
28
|
-
.addHelpText('after', 'It runs the install command if you have not installed the dependencies yet.')
|
|
29
|
-
.action(async (options, command) => {
|
|
30
|
-
const { lmSetup } = await import('./lm-setup.js');
|
|
31
|
-
await lmSetup(options, command);
|
|
32
|
-
});
|
|
33
|
-
program
|
|
34
|
-
.command('lm:uninstall', { hidden: true })
|
|
35
|
-
.alias('lm:remove')
|
|
36
|
-
.description('Uninstalls Netlify git credentials helper and cleans up any related configuration changes made by the install command.')
|
|
37
|
-
.action(async () => {
|
|
38
|
-
const { lmUninstall } = await import('./lm-uninstall.js');
|
|
39
|
-
await lmUninstall();
|
|
40
|
-
});
|
|
41
|
-
program
|
|
42
|
-
.command('lm', { hidden: true })
|
|
43
|
-
.description('[Deprecated and will be removed from future versions] Handle Netlify Large Media operations\nThe lm command will help you manage large media for a site')
|
|
44
|
-
.addExamples(['netlify lm:info', 'netlify lm:install', 'netlify lm:setup'])
|
|
45
|
-
.action(lm);
|
|
46
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../src/utils/addons/render.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,mBAAmB,sCAU/B,CAAA;AAGD,eAAO,MAAM,kBAAkB,0DAsB9B,CAAA"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import AsciiTable from 'ascii-table';
|
|
2
|
-
import { chalk } from '../command-helpers.js';
|
|
3
|
-
// @ts-expect-error TS(7006) FIXME: Parameter 'values' implicitly has an 'any' type.
|
|
4
|
-
export const renderMissingValues = function (values, manifest) {
|
|
5
|
-
const display = values
|
|
6
|
-
// @ts-expect-error TS(7006) FIXME: Parameter 'item' implicitly has an 'any' type.
|
|
7
|
-
.map((item) => {
|
|
8
|
-
const itemDisplay = chalk.redBright.bold(`${item}`);
|
|
9
|
-
const niceNameDisplay = manifest.config[item].displayName;
|
|
10
|
-
return ` - ${itemDisplay} ${niceNameDisplay}`;
|
|
11
|
-
})
|
|
12
|
-
.join('\n');
|
|
13
|
-
console.log(display);
|
|
14
|
-
};
|
|
15
|
-
// @ts-expect-error TS(7006) FIXME: Parameter 'addonName' implicitly has an 'any' type... Remove this comment to see the full error message
|
|
16
|
-
export const renderConfigValues = function (addonName, values, currentValue) {
|
|
17
|
-
const table = new AsciiTable(`${addonName} add-on settings`);
|
|
18
|
-
const tableHeader = currentValue
|
|
19
|
-
? ['Setting Name', 'Current Value', 'Description']
|
|
20
|
-
: ['Setting Name', 'Description', 'Type', 'Required'];
|
|
21
|
-
table.setHeading(...tableHeader);
|
|
22
|
-
Object.keys(values).forEach((key) => {
|
|
23
|
-
const { displayName, required, type } = values[key];
|
|
24
|
-
const requiredText = required ? `true` : `false`;
|
|
25
|
-
const typeInfo = type || '';
|
|
26
|
-
const description = displayName || '';
|
|
27
|
-
if (currentValue) {
|
|
28
|
-
const value = currentValue[key] || 'Not supplied';
|
|
29
|
-
table.addRow(key, value, description);
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
table.addRow(key, description, typeInfo, requiredText);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
console.log(table.toString());
|
|
36
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export declare const installPlatform: ({ force }: {
|
|
2
|
-
force: any;
|
|
3
|
-
}) => Promise<boolean>;
|
|
4
|
-
export declare const isBinInPath: () => boolean;
|
|
5
|
-
export declare const getShellInfo: () => {
|
|
6
|
-
shell: string | undefined;
|
|
7
|
-
incFilePath: string;
|
|
8
|
-
configFile: any;
|
|
9
|
-
};
|
|
10
|
-
export declare const uninstall: () => Promise<void>;
|
|
11
|
-
//# sourceMappingURL=install.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../../src/utils/lm/install.ts"],"names":[],"mappings":"AA0EA,eAAO,MAAM,eAAe;;sBAoB3B,CAAA;AAsCD,eAAO,MAAM,WAAW,eAKvB,CAAA;AAmHD,eAAO,MAAM,YAAY;;;;CAaxB,CAAA;AAaD,eAAO,MAAM,SAAS,qBAMrB,CAAA"}
|
package/dist/utils/lm/install.js
DELETED
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
import { appendFile, copyFile, readFile, rm, writeFile } from 'fs/promises';
|
|
2
|
-
import os from 'os';
|
|
3
|
-
import path, { join, sep } from 'path';
|
|
4
|
-
import process from 'process';
|
|
5
|
-
import { fileURLToPath } from 'url';
|
|
6
|
-
import execa from 'execa';
|
|
7
|
-
// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'hasb... Remove this comment to see the full error message
|
|
8
|
-
import hasbin from 'hasbin';
|
|
9
|
-
import { Listr } from 'listr2';
|
|
10
|
-
import pathKey from 'path-key';
|
|
11
|
-
import { fetchLatestVersion, shouldFetchLatestVersion } from '../../lib/exec-fetcher.js';
|
|
12
|
-
import { fileExistsAsync } from '../../lib/fs.js';
|
|
13
|
-
import { normalizeBackslash } from '../../lib/path.js';
|
|
14
|
-
import { getLegacyPathInHome, getPathInHome } from '../../lib/settings.js';
|
|
15
|
-
import { chalk } from '../command-helpers.js';
|
|
16
|
-
import { checkGitLFSVersionStep, checkGitVersionStep, checkLFSFiltersStep } from './steps.js';
|
|
17
|
-
const PACKAGE_NAME = 'netlify-credential-helper';
|
|
18
|
-
const EXEC_NAME = 'git-credential-netlify';
|
|
19
|
-
const GIT_CONFIG = '.gitconfig';
|
|
20
|
-
const SUPPORTED_PLATFORMS = {
|
|
21
|
-
linux: 'Linux',
|
|
22
|
-
darwin: 'Mac OS X',
|
|
23
|
-
win32: 'Windows',
|
|
24
|
-
};
|
|
25
|
-
const CONFIG_FILES = {
|
|
26
|
-
bash: '.bashrc',
|
|
27
|
-
zsh: '.zshrc',
|
|
28
|
-
fish: '.config/fish/config.fish',
|
|
29
|
-
};
|
|
30
|
-
/** The path to the scritps folder on the package root */
|
|
31
|
-
const scriptsPath = fileURLToPath(new URL('../../../scripts', import.meta.url));
|
|
32
|
-
const getHelperPath = () => getPathInHome(['helper']);
|
|
33
|
-
const getBinPath = () => join(getHelperPath(), 'bin');
|
|
34
|
-
const getGitConfigPath = () => join(getHelperPath(), 'git-config');
|
|
35
|
-
const getLegacyBinPath = () => join(getLegacyPathInHome(['helper', 'bin']));
|
|
36
|
-
// @ts-expect-error TS(7031) FIXME: Binding element 'skipInstall' implicitly has an 'a... Remove this comment to see the full error message
|
|
37
|
-
const getSetupStep = ({ skipInstall }) => {
|
|
38
|
-
const platform = os.platform();
|
|
39
|
-
// @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
|
|
40
|
-
const platformName = SUPPORTED_PLATFORMS[platform];
|
|
41
|
-
if (platformName === undefined) {
|
|
42
|
-
throw new Error(`Platform not supported: ${platform}.
|
|
43
|
-
See manual setup instructions in https://github.com/netlify/netlify-credential-helper#install`);
|
|
44
|
-
}
|
|
45
|
-
return {
|
|
46
|
-
title: `Installing Netlify's Git Credential Helper for ${platformName}`,
|
|
47
|
-
skip: () => {
|
|
48
|
-
if (skipInstall) {
|
|
49
|
-
return `Netlify's Git Credential Helper already installed with a package manager`;
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
task: async () => {
|
|
53
|
-
await installHelper();
|
|
54
|
-
await (platform === 'win32' ? setupWindowsPath() : setupUnixPath());
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
const setupGitConfigStep = {
|
|
59
|
-
title: `Configuring Git to use Netlify's Git Credential Helper`,
|
|
60
|
-
task: () => configureGitConfig(),
|
|
61
|
-
};
|
|
62
|
-
// @ts-expect-error TS(7031) FIXME: Binding element 'force' implicitly has an 'any' ty... Remove this comment to see the full error message
|
|
63
|
-
export const installPlatform = async function ({ force }) {
|
|
64
|
-
const skipInstall = !force && (await installedWithPackageManager());
|
|
65
|
-
const steps = [
|
|
66
|
-
checkGitVersionStep,
|
|
67
|
-
checkGitLFSVersionStep,
|
|
68
|
-
// @ts-expect-error TS(7006) FIXME: Parameter 'ctx' implicitly has an 'any' type.
|
|
69
|
-
checkLFSFiltersStep(async (ctx, task, installed) => {
|
|
70
|
-
if (!installed) {
|
|
71
|
-
await execa('git', ['lfs', 'install']);
|
|
72
|
-
task.title += chalk.dim(' [installed]');
|
|
73
|
-
}
|
|
74
|
-
}),
|
|
75
|
-
getSetupStep({ skipInstall }),
|
|
76
|
-
setupGitConfigStep,
|
|
77
|
-
];
|
|
78
|
-
const tasks = new Listr(steps);
|
|
79
|
-
await tasks.run();
|
|
80
|
-
return !skipInstall;
|
|
81
|
-
};
|
|
82
|
-
const installedWithPackageManager = async function () {
|
|
83
|
-
const installed = hasbin.sync('git-credential-netlify');
|
|
84
|
-
if (!installed) {
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
// we check for the older location too via getLegacyBinPath
|
|
88
|
-
const binExist = await Promise.all([getBinPath(), getLegacyBinPath()].map(fileExistsAsync));
|
|
89
|
-
const withPackageManager = binExist.every((exists) => !exists);
|
|
90
|
-
return withPackageManager;
|
|
91
|
-
};
|
|
92
|
-
const installHelper = async function () {
|
|
93
|
-
// remove any old versions that might still exist in `~/.netlify/helper/bin`
|
|
94
|
-
await rm(getLegacyBinPath(), { force: true, recursive: true });
|
|
95
|
-
const binPath = getBinPath();
|
|
96
|
-
// @ts-expect-error TS(2345) FIXME: Argument of type '{ binPath: string; packageName: ... Remove this comment to see the full error message
|
|
97
|
-
const shouldFetch = await shouldFetchLatestVersion({
|
|
98
|
-
binPath,
|
|
99
|
-
packageName: PACKAGE_NAME,
|
|
100
|
-
execArgs: ['version'],
|
|
101
|
-
pattern: `${EXEC_NAME}\\/v?([^\\s]+)`,
|
|
102
|
-
execName: EXEC_NAME,
|
|
103
|
-
});
|
|
104
|
-
if (!shouldFetch) {
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
// @ts-expect-error TS(2345) FIXME: Argument of type '{ packageName: string; execName:... Remove this comment to see the full error message
|
|
108
|
-
await fetchLatestVersion({
|
|
109
|
-
packageName: PACKAGE_NAME,
|
|
110
|
-
execName: EXEC_NAME,
|
|
111
|
-
destination: binPath,
|
|
112
|
-
extension: process.platform === 'win32' ? 'zip' : 'tar.gz',
|
|
113
|
-
});
|
|
114
|
-
};
|
|
115
|
-
export const isBinInPath = () => {
|
|
116
|
-
const envPath = process.env[pathKey()];
|
|
117
|
-
const binPath = getBinPath();
|
|
118
|
-
// @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'.
|
|
119
|
-
return envPath.replace(/"+/g, '').split(path.delimiter).includes(binPath);
|
|
120
|
-
};
|
|
121
|
-
const setupWindowsPath = async function () {
|
|
122
|
-
if (isBinInPath()) {
|
|
123
|
-
return true;
|
|
124
|
-
}
|
|
125
|
-
const scriptPath = join(scriptsPath, 'path.ps1');
|
|
126
|
-
return await execa('powershell', ['-ExecutionPolicy', 'unrestricted', '-windowstyle', 'hidden', '-File', scriptPath, getBinPath()], { stdio: 'inherit' });
|
|
127
|
-
};
|
|
128
|
-
const CONTENT_COMMENT = `
|
|
129
|
-
# The next line updates PATH for Netlify's Git Credential Helper.
|
|
130
|
-
`;
|
|
131
|
-
// @ts-expect-error TS(7006) FIXME: Parameter 'incFilePath' implicitly has an 'any' ty... Remove this comment to see the full error message
|
|
132
|
-
const getInitContent = (incFilePath) => `${CONTENT_COMMENT}test -f '${incFilePath}' && source '${incFilePath}'`;
|
|
133
|
-
const setupUnixPath = async () => {
|
|
134
|
-
if (isBinInPath()) {
|
|
135
|
-
return true;
|
|
136
|
-
}
|
|
137
|
-
const { configFile, incFilePath, shell } = getShellInfo();
|
|
138
|
-
if (configFile === undefined) {
|
|
139
|
-
const error = `Unable to set credential helper in PATH. We don't how to set the path for ${shell} shell.
|
|
140
|
-
Set the helper path in your environment PATH: ${getBinPath()}`;
|
|
141
|
-
throw new Error(error);
|
|
142
|
-
}
|
|
143
|
-
return await Promise.all([
|
|
144
|
-
await copyFile(join(scriptsPath, `${shell}.sh`), incFilePath),
|
|
145
|
-
await writeConfig(configFile, getInitContent(incFilePath)),
|
|
146
|
-
]);
|
|
147
|
-
};
|
|
148
|
-
// @ts-expect-error TS(7006) FIXME: Parameter 'name' implicitly has an 'any' type.
|
|
149
|
-
const writeConfig = async function (name, initContent) {
|
|
150
|
-
const configPath = join(os.homedir(), name);
|
|
151
|
-
if (!(await fileExistsAsync(configPath))) {
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
const content = await readFile(configPath, 'utf8');
|
|
155
|
-
if (content.includes(initContent)) {
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
return await appendFile(configPath, initContent, 'utf-8');
|
|
159
|
-
};
|
|
160
|
-
const getCurrentCredentials = async () => {
|
|
161
|
-
try {
|
|
162
|
-
const { stdout } = await execa('git', ['config', '--no-includes', '--get-regexp', '^credential']);
|
|
163
|
-
const currentCredentials = stdout.split('\\n');
|
|
164
|
-
return currentCredentials;
|
|
165
|
-
}
|
|
166
|
-
catch (error) {
|
|
167
|
-
// ignore error caused by not having any credential configured
|
|
168
|
-
// @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
|
|
169
|
-
if (error.stdout !== '') {
|
|
170
|
-
throw error;
|
|
171
|
-
}
|
|
172
|
-
return [];
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
// Git expects the config path to always use / even on Windows
|
|
176
|
-
// @ts-expect-error TS(7006) FIXME: Parameter 'gitConfigPath' implicitly has an 'any' ... Remove this comment to see the full error message
|
|
177
|
-
const getGitConfigContent = (gitConfigPath) => `
|
|
178
|
-
# This next lines include Netlify's Git Credential Helper configuration in your Git configuration.
|
|
179
|
-
[include]
|
|
180
|
-
path = ${normalizeBackslash(gitConfigPath)}
|
|
181
|
-
`;
|
|
182
|
-
const configureGitConfig = async function () {
|
|
183
|
-
const currentCredentials = await getCurrentCredentials();
|
|
184
|
-
let helperConfig = `
|
|
185
|
-
# The first line resets the list of helpers so we can check Netlify's first.
|
|
186
|
-
[credential]
|
|
187
|
-
helper = ""
|
|
188
|
-
|
|
189
|
-
[credential]
|
|
190
|
-
helper = netlify
|
|
191
|
-
`;
|
|
192
|
-
let section = 'credential';
|
|
193
|
-
if (currentCredentials.length !== 0) {
|
|
194
|
-
currentCredentials.forEach((line) => {
|
|
195
|
-
const parts = line.split(' ');
|
|
196
|
-
if (parts.length === 2) {
|
|
197
|
-
const keys = parts[0].split('.');
|
|
198
|
-
const localSection = keys.slice(0, -1).join('.');
|
|
199
|
-
if (section !== localSection) {
|
|
200
|
-
helperConfig += keys.length > 2 ? `\n[credential "${keys[1]}"]\n` : '\n[credential]\n';
|
|
201
|
-
section = localSection;
|
|
202
|
-
}
|
|
203
|
-
helperConfig += ` ${keys.pop()} = ${parts[1]}\n`;
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
const gitConfigPath = getGitConfigPath();
|
|
208
|
-
await writeFile(gitConfigPath, helperConfig, 'utf-8');
|
|
209
|
-
return writeConfig(GIT_CONFIG, getGitConfigContent(gitConfigPath));
|
|
210
|
-
};
|
|
211
|
-
export const getShellInfo = function () {
|
|
212
|
-
const shellEnv = process.env.SHELL;
|
|
213
|
-
if (!shellEnv) {
|
|
214
|
-
throw new Error('Unable to detect SHELL type, make sure the variable is defined in your environment');
|
|
215
|
-
}
|
|
216
|
-
const shell = shellEnv.split(sep).pop();
|
|
217
|
-
return {
|
|
218
|
-
shell,
|
|
219
|
-
incFilePath: `${getHelperPath()}/path.${shell}.inc`,
|
|
220
|
-
// @ts-expect-error TS(2538) FIXME: Type 'undefined' cannot be used as an index type.
|
|
221
|
-
configFile: CONFIG_FILES[shell],
|
|
222
|
-
};
|
|
223
|
-
};
|
|
224
|
-
const cleanupShell = async function () {
|
|
225
|
-
try {
|
|
226
|
-
const { configFile, incFilePath } = getShellInfo();
|
|
227
|
-
if (configFile === undefined) {
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
|
-
await removeConfig(configFile, getInitContent(incFilePath));
|
|
231
|
-
}
|
|
232
|
-
catch { }
|
|
233
|
-
};
|
|
234
|
-
export const uninstall = async function () {
|
|
235
|
-
await Promise.all([
|
|
236
|
-
rm(getHelperPath(), { force: true, recursive: true }),
|
|
237
|
-
removeConfig(GIT_CONFIG, getGitConfigContent(getGitConfigPath())),
|
|
238
|
-
cleanupShell(),
|
|
239
|
-
]);
|
|
240
|
-
};
|
|
241
|
-
const removeConfig = async function (name, toRemove) {
|
|
242
|
-
const configPath = join(os.homedir(), name);
|
|
243
|
-
if (!(await fileExistsAsync(configPath))) {
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
|
-
const content = await readFile(configPath, 'utf8');
|
|
247
|
-
return await writeFile(configPath, content.replace(toRemove, ''));
|
|
248
|
-
};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export declare const checkLFSFilters: () => Promise<boolean>;
|
|
2
|
-
export declare const checkHelperVersion: () => Promise<any>;
|
|
3
|
-
export declare const checkGitVersion: () => Promise<string | undefined>;
|
|
4
|
-
export declare const checkLFSVersion: () => Promise<any>;
|
|
5
|
-
//# sourceMappingURL=requirements.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"requirements.d.ts","sourceRoot":"","sources":["../../../src/utils/lm/requirements.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,eAAe,wBAO3B,CAAA;AAWD,eAAO,MAAM,kBAAkB,oBAS9B,CAAA;AAED,eAAO,MAAM,eAAe,mCAO3B,CAAA;AAWD,eAAO,MAAM,eAAe,oBAS3B,CAAA"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import semver from 'semver';
|
|
2
|
-
import execa from '../execa.js';
|
|
3
|
-
export const checkLFSFilters = async function () {
|
|
4
|
-
try {
|
|
5
|
-
const { stdout } = await execa('git', ['config', '--get-regexp', 'filter.lfs']);
|
|
6
|
-
return stdout.length !== 0;
|
|
7
|
-
}
|
|
8
|
-
catch {
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
const getHelperVersion = async function () {
|
|
13
|
-
try {
|
|
14
|
-
const { stdout } = await execa('git-credential-netlify', ['version']);
|
|
15
|
-
return stdout;
|
|
16
|
-
}
|
|
17
|
-
catch {
|
|
18
|
-
throw new Error(`Check that Netlify's Git Credential helper is installed and updated to the latest version`);
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
export const checkHelperVersion = async function () {
|
|
22
|
-
const version = await getHelperVersion();
|
|
23
|
-
const expectedVersion = '0.1.10';
|
|
24
|
-
return matchVersion(version, /git-credential-netlify\/([.\d]+).*/, expectedVersion, `Invalid Netlify's Git Credential version MATCH_PLACEHOLDER. Please update to version ${expectedVersion} or above by running 'ntl lm:install'`);
|
|
25
|
-
};
|
|
26
|
-
export const checkGitVersion = async function () {
|
|
27
|
-
try {
|
|
28
|
-
const { stdout } = await execa('git', ['--version']);
|
|
29
|
-
return stdout.split(' ').pop();
|
|
30
|
-
}
|
|
31
|
-
catch {
|
|
32
|
-
throw new Error('Check that Git is installed in your system');
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
const getLFSVersion = async function () {
|
|
36
|
-
try {
|
|
37
|
-
const { stdout } = await execa('git-lfs', ['version']);
|
|
38
|
-
return stdout;
|
|
39
|
-
}
|
|
40
|
-
catch {
|
|
41
|
-
throw new Error('Check that Git LFS is installed in your system');
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
export const checkLFSVersion = async function () {
|
|
45
|
-
const version = await getLFSVersion();
|
|
46
|
-
const expectedVersion = '2.5.1';
|
|
47
|
-
return matchVersion(version, /git-lfs\/([.\d]+).*/, expectedVersion, `Invalid Git LFS version MATCH_PLACEHOLDER. Please update to version ${expectedVersion} or above`);
|
|
48
|
-
};
|
|
49
|
-
// @ts-expect-error TS(7006) FIXME: Parameter 'out' implicitly has an 'any' type.
|
|
50
|
-
const matchVersion = function (out, regex, version, message) {
|
|
51
|
-
const match = out.match(regex);
|
|
52
|
-
if (!match || match.length !== 2 || semver.lt(match[1], version)) {
|
|
53
|
-
throw new Error(message.replace('MATCH_PLACEHOLDER', match[1]));
|
|
54
|
-
}
|
|
55
|
-
return match[1];
|
|
56
|
-
};
|
package/dist/utils/lm/steps.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export declare const checkGitVersionStep: {
|
|
2
|
-
title: string;
|
|
3
|
-
task: (ctx: any, task: any) => Promise<void>;
|
|
4
|
-
};
|
|
5
|
-
export declare const checkGitLFSVersionStep: {
|
|
6
|
-
title: string;
|
|
7
|
-
task: (ctx: any, task: any) => Promise<void>;
|
|
8
|
-
};
|
|
9
|
-
export declare const checkLFSFiltersStep: (onCheckDone: any) => {
|
|
10
|
-
title: string;
|
|
11
|
-
task: (ctx: any, task: any) => Promise<any>;
|
|
12
|
-
};
|
|
13
|
-
export declare const checkHelperVersionStep: {
|
|
14
|
-
title: string;
|
|
15
|
-
task: (ctx: any, task: any) => Promise<void>;
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=steps.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"steps.d.ts","sourceRoot":"","sources":["../../../src/utils/lm/steps.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,mBAAmB;;;CAO/B,CAAA;AAED,eAAO,MAAM,sBAAsB;;;CAOlC,CAAA;AAGD,eAAO,MAAM,mBAAmB;;;CAO9B,CAAA;AAEF,eAAO,MAAM,sBAAsB;;;CAOlC,CAAA"}
|
package/dist/utils/lm/steps.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { chalk } from '../command-helpers.js';
|
|
2
|
-
import { checkGitVersion, checkHelperVersion, checkLFSFilters, checkLFSVersion } from './requirements.js';
|
|
3
|
-
export const checkGitVersionStep = {
|
|
4
|
-
title: 'Checking Git version',
|
|
5
|
-
// @ts-expect-error TS(7006) FIXME: Parameter 'ctx' implicitly has an 'any' type.
|
|
6
|
-
task: async (ctx, task) => {
|
|
7
|
-
const version = await checkGitVersion();
|
|
8
|
-
task.title += chalk.dim(` [${version}]`);
|
|
9
|
-
},
|
|
10
|
-
};
|
|
11
|
-
export const checkGitLFSVersionStep = {
|
|
12
|
-
title: 'Checking Git LFS version',
|
|
13
|
-
// @ts-expect-error TS(7006) FIXME: Parameter 'ctx' implicitly has an 'any' type.
|
|
14
|
-
task: async (ctx, task) => {
|
|
15
|
-
const version = await checkLFSVersion();
|
|
16
|
-
task.title += chalk.dim(` [${version}]`);
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
// @ts-expect-error TS(7006) FIXME: Parameter 'onCheckDone' implicitly has an 'any' ty... Remove this comment to see the full error message
|
|
20
|
-
export const checkLFSFiltersStep = (onCheckDone) => ({
|
|
21
|
-
title: 'Checking Git LFS filters',
|
|
22
|
-
// @ts-expect-error TS(7006) FIXME: Parameter 'ctx' implicitly has an 'any' type.
|
|
23
|
-
task: async (ctx, task) => {
|
|
24
|
-
const installed = await checkLFSFilters();
|
|
25
|
-
return onCheckDone(ctx, task, installed);
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
export const checkHelperVersionStep = {
|
|
29
|
-
title: `Checking Netlify's Git Credentials version`,
|
|
30
|
-
// @ts-expect-error TS(7006) FIXME: Parameter 'ctx' implicitly has an 'any' type.
|
|
31
|
-
task: async (ctx, task) => {
|
|
32
|
-
const version = await checkHelperVersion();
|
|
33
|
-
task.title += chalk.dim(` [${version}]`);
|
|
34
|
-
},
|
|
35
|
-
};
|
package/dist/utils/lm/ui.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../../src/utils/lm/ui.ts"],"names":[],"mappings":"AAQA;;GAEG;AAEH,eAAO,MAAM,WAAW,sBAYvB,CAAA"}
|
package/dist/utils/lm/ui.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import os from 'os';
|
|
2
|
-
import boxen from 'boxen';
|
|
3
|
-
import { chalk, log } from '../command-helpers.js';
|
|
4
|
-
import { getShellInfo, isBinInPath } from './install.js';
|
|
5
|
-
/**
|
|
6
|
-
* @param {boolean} force
|
|
7
|
-
*/
|
|
8
|
-
// @ts-expect-error TS(7006) FIXME: Parameter 'force' implicitly has an 'any' type.
|
|
9
|
-
export const printBanner = function (force) {
|
|
10
|
-
const print = force || !isBinInPath();
|
|
11
|
-
const platform = os.platform();
|
|
12
|
-
if (print && platform !== 'win32') {
|
|
13
|
-
const { incFilePath } = getShellInfo();
|
|
14
|
-
const banner = chalk.bold(`Run this command to use Netlify Large Media in your current shell\n\nsource ${incFilePath}`);
|
|
15
|
-
log(boxen(banner, { padding: 1, margin: 1, align: 'center', borderColor: '#00c7b7' }));
|
|
16
|
-
}
|
|
17
|
-
};
|