@vercel/cli-config 0.1.2 → 0.2.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/cli-config.d.ts +10 -5
- package/dist/cli-config.js +58 -31
- package/dist/cred-storage.d.ts +3 -0
- package/dist/cred-storage.js +73 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/paths.d.ts +4 -0
- package/dist/paths.js +54 -0
- package/dist/schema.d.ts +3 -2
- package/dist/schema.js +14 -1
- package/dist/schema.zod.d.ts +12 -0
- package/dist/schema.zod.js +11 -1
- package/dist/types.d.ts +9 -0
- package/dist/types.js +8 -0
- package/package.json +3 -2
package/dist/cli-config.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import type { AuthConfig, GlobalConfig } from './types';
|
|
2
|
+
import type { AuthConfig, AuthFileConfig, GlobalConfig } from './types';
|
|
3
|
+
import { getAuthConfigFilePath, getConfigFilePath, getGlobalPathConfig } from './paths';
|
|
4
|
+
export { getAuthConfigFilePath, getConfigFilePath, getGlobalPathConfig };
|
|
3
5
|
type WriteConfigFileOptions = {
|
|
4
6
|
indent?: number | string;
|
|
5
7
|
mode?: number;
|
|
@@ -9,13 +11,16 @@ export declare function getDefaultAuthConfig(): AuthConfig;
|
|
|
9
11
|
export declare const defaultAuthConfig: AuthConfig;
|
|
10
12
|
export declare function parseGlobalConfig(value: unknown): GlobalConfig;
|
|
11
13
|
export declare function parseAuthConfig(value: unknown): AuthConfig;
|
|
14
|
+
export declare function parseAuthFileConfig(value: unknown): AuthFileConfig;
|
|
12
15
|
export declare function readConfigFile<S extends z.ZodType>(configPath: string, schema: S): z.output<S>;
|
|
13
16
|
export declare function writeConfigFile<S extends z.ZodType>(configPath: string, schema: S, config: z.output<S>, options?: WriteConfigFileOptions): void;
|
|
14
|
-
export declare function getGlobalPathConfig(): string;
|
|
15
|
-
export declare function getConfigFilePath(configDir: string): string;
|
|
16
|
-
export declare function getAuthConfigFilePath(configDir: string): string;
|
|
17
17
|
export declare function readGlobalConfigFile(configPath: string): GlobalConfig;
|
|
18
18
|
export declare function writeGlobalConfigFile(configPath: string, config: GlobalConfig): void;
|
|
19
19
|
export declare function readAuthConfigFile(configPath: string): AuthConfig;
|
|
20
|
+
export declare function readAuthFileConfig(configPath: string): AuthFileConfig;
|
|
21
|
+
export declare function readAuthConfig(configDir: string): AuthConfig;
|
|
22
|
+
export declare function tryReadAuthConfig(configDir: string): AuthConfig | null;
|
|
20
23
|
export declare function writeAuthConfigFile(configPath: string, authConfig: AuthConfig): void;
|
|
21
|
-
export
|
|
24
|
+
export declare function writeAuthConfig(configDir: string, authConfig: AuthConfig): void;
|
|
25
|
+
export declare function deleteAuthConfigFile(configPath: string): void;
|
|
26
|
+
export declare function deleteAuthConfig(configDir: string): void;
|
package/dist/cli-config.js
CHANGED
|
@@ -3,25 +3,31 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.defaultAuthConfig = exports.defaultGlobalConfig = void 0;
|
|
6
|
+
exports.defaultAuthConfig = exports.defaultGlobalConfig = exports.getGlobalPathConfig = exports.getConfigFilePath = exports.getAuthConfigFilePath = void 0;
|
|
7
7
|
exports.getDefaultAuthConfig = getDefaultAuthConfig;
|
|
8
8
|
exports.parseGlobalConfig = parseGlobalConfig;
|
|
9
9
|
exports.parseAuthConfig = parseAuthConfig;
|
|
10
|
+
exports.parseAuthFileConfig = parseAuthFileConfig;
|
|
10
11
|
exports.readConfigFile = readConfigFile;
|
|
11
12
|
exports.writeConfigFile = writeConfigFile;
|
|
12
|
-
exports.getGlobalPathConfig = getGlobalPathConfig;
|
|
13
|
-
exports.getConfigFilePath = getConfigFilePath;
|
|
14
|
-
exports.getAuthConfigFilePath = getAuthConfigFilePath;
|
|
15
13
|
exports.readGlobalConfigFile = readGlobalConfigFile;
|
|
16
14
|
exports.writeGlobalConfigFile = writeGlobalConfigFile;
|
|
17
15
|
exports.readAuthConfigFile = readAuthConfigFile;
|
|
16
|
+
exports.readAuthFileConfig = readAuthFileConfig;
|
|
17
|
+
exports.readAuthConfig = readAuthConfig;
|
|
18
|
+
exports.tryReadAuthConfig = tryReadAuthConfig;
|
|
18
19
|
exports.writeAuthConfigFile = writeAuthConfigFile;
|
|
20
|
+
exports.writeAuthConfig = writeAuthConfig;
|
|
21
|
+
exports.deleteAuthConfigFile = deleteAuthConfigFile;
|
|
22
|
+
exports.deleteAuthConfig = deleteAuthConfig;
|
|
19
23
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
20
24
|
const node_path_1 = __importDefault(require("node:path"));
|
|
21
|
-
const node_os_1 = require("node:os");
|
|
22
|
-
const xdg_app_paths_1 = __importDefault(require("xdg-app-paths"));
|
|
23
25
|
const zod_1 = require("zod");
|
|
24
26
|
const schema_1 = require("./schema");
|
|
27
|
+
const paths_1 = require("./paths");
|
|
28
|
+
Object.defineProperty(exports, "getAuthConfigFilePath", { enumerable: true, get: function () { return paths_1.getAuthConfigFilePath; } });
|
|
29
|
+
Object.defineProperty(exports, "getConfigFilePath", { enumerable: true, get: function () { return paths_1.getConfigFilePath; } });
|
|
30
|
+
Object.defineProperty(exports, "getGlobalPathConfig", { enumerable: true, get: function () { return paths_1.getGlobalPathConfig; } });
|
|
25
31
|
const DOCS_URL = 'https://vercel.com/docs/projects/project-configuration/global-configuration';
|
|
26
32
|
exports.defaultGlobalConfig = {
|
|
27
33
|
'// Note': 'This is your Vercel config file. For more information see the global configuration documentation.',
|
|
@@ -34,12 +40,30 @@ function getDefaultAuthConfig() {
|
|
|
34
40
|
};
|
|
35
41
|
}
|
|
36
42
|
exports.defaultAuthConfig = getDefaultAuthConfig();
|
|
43
|
+
function normalizeConfigError(error) {
|
|
44
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
45
|
+
const credStorageIssue = error.issues.find(issue => issue.path[0] === 'credStorage');
|
|
46
|
+
if (credStorageIssue) {
|
|
47
|
+
throw new Error(credStorageIssue.message);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
37
52
|
function parseGlobalConfig(value) {
|
|
38
|
-
|
|
53
|
+
try {
|
|
54
|
+
return schema_1.globalConfigSchema.parse(value);
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
normalizeConfigError(error);
|
|
58
|
+
}
|
|
39
59
|
}
|
|
40
60
|
function parseAuthConfig(value) {
|
|
41
61
|
return schema_1.authConfigSchema.parse(value);
|
|
42
62
|
}
|
|
63
|
+
function parseAuthFileConfig(value) {
|
|
64
|
+
const { tokenSource, ...authConfig } = parseAuthConfig(value);
|
|
65
|
+
return authConfig;
|
|
66
|
+
}
|
|
43
67
|
function readJsonFileSync(filePath) {
|
|
44
68
|
const content = node_fs_1.default.readFileSync(filePath, 'utf8').replace(/^\uFEFF/, '');
|
|
45
69
|
return JSON.parse(content);
|
|
@@ -76,40 +100,34 @@ function writeConfigFile(configPath, schema, config, options) {
|
|
|
76
100
|
...options,
|
|
77
101
|
});
|
|
78
102
|
}
|
|
79
|
-
function
|
|
103
|
+
function readGlobalConfigFile(configPath) {
|
|
80
104
|
try {
|
|
81
|
-
return
|
|
105
|
+
return readConfigFile(configPath, schema_1.globalConfigSchema);
|
|
82
106
|
}
|
|
83
|
-
catch (
|
|
84
|
-
|
|
85
|
-
return false;
|
|
107
|
+
catch (error) {
|
|
108
|
+
normalizeConfigError(error);
|
|
86
109
|
}
|
|
87
110
|
}
|
|
88
|
-
function getGlobalPathConfig() {
|
|
89
|
-
const vercelDirectories = (0, xdg_app_paths_1.default)('com.vercel.cli').dataDirs();
|
|
90
|
-
const possibleConfigPaths = [
|
|
91
|
-
...vercelDirectories, // latest vercel directory
|
|
92
|
-
node_path_1.default.join((0, node_os_1.homedir)(), '.now'), // legacy config in user's home directory
|
|
93
|
-
...(0, xdg_app_paths_1.default)('now').dataDirs(), // legacy XDG directory
|
|
94
|
-
];
|
|
95
|
-
return (possibleConfigPaths.find(configPath => isReadableDirectory(configPath)) ||
|
|
96
|
-
vercelDirectories[0]);
|
|
97
|
-
}
|
|
98
|
-
function getConfigFilePath(configDir) {
|
|
99
|
-
return node_path_1.default.join(configDir, 'config.json');
|
|
100
|
-
}
|
|
101
|
-
function getAuthConfigFilePath(configDir) {
|
|
102
|
-
return node_path_1.default.join(configDir, 'auth.json');
|
|
103
|
-
}
|
|
104
|
-
function readGlobalConfigFile(configPath) {
|
|
105
|
-
return readConfigFile(configPath, schema_1.globalConfigSchema);
|
|
106
|
-
}
|
|
107
111
|
function writeGlobalConfigFile(configPath, config) {
|
|
108
112
|
writeConfigFile(configPath, schema_1.globalConfigSchema, config);
|
|
109
113
|
}
|
|
110
114
|
function readAuthConfigFile(configPath) {
|
|
111
115
|
return readConfigFile(configPath, schema_1.authConfigSchema);
|
|
112
116
|
}
|
|
117
|
+
function readAuthFileConfig(configPath) {
|
|
118
|
+
return parseAuthFileConfig(readJsonFileSync(configPath));
|
|
119
|
+
}
|
|
120
|
+
function readAuthConfig(configDir) {
|
|
121
|
+
return readAuthConfigFile((0, paths_1.getAuthConfigFilePath)(configDir));
|
|
122
|
+
}
|
|
123
|
+
function tryReadAuthConfig(configDir) {
|
|
124
|
+
try {
|
|
125
|
+
return readAuthConfig(configDir);
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
113
131
|
function writeAuthConfigFile(configPath, authConfig) {
|
|
114
132
|
if (authConfig.skipWrite) {
|
|
115
133
|
return;
|
|
@@ -118,3 +136,12 @@ function writeAuthConfigFile(configPath, authConfig) {
|
|
|
118
136
|
mode: 0o600,
|
|
119
137
|
});
|
|
120
138
|
}
|
|
139
|
+
function writeAuthConfig(configDir, authConfig) {
|
|
140
|
+
writeAuthConfigFile((0, paths_1.getAuthConfigFilePath)(configDir), authConfig);
|
|
141
|
+
}
|
|
142
|
+
function deleteAuthConfigFile(configPath) {
|
|
143
|
+
node_fs_1.default.rmSync(configPath, { force: true });
|
|
144
|
+
}
|
|
145
|
+
function deleteAuthConfig(configDir) {
|
|
146
|
+
deleteAuthConfigFile((0, paths_1.getAuthConfigFilePath)(configDir));
|
|
147
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.authConfigHasUsableTokenData = authConfigHasUsableTokenData;
|
|
4
|
+
exports.getLikelyEffectiveCredStorage = getLikelyEffectiveCredStorage;
|
|
5
|
+
const types_1 = require("./types");
|
|
6
|
+
const cli_config_1 = require("./cli-config");
|
|
7
|
+
const TOKEN_STORAGE_ENV = 'VERCEL_TOKEN_STORAGE';
|
|
8
|
+
function isErrnoException(error) {
|
|
9
|
+
return typeof error === 'object' && error !== null && 'code' in error;
|
|
10
|
+
}
|
|
11
|
+
function isCredStorage(value) {
|
|
12
|
+
return types_1.CRED_STORAGE_CONFIG_VALUES.includes(value);
|
|
13
|
+
}
|
|
14
|
+
function formatCredStorageError(value, source) {
|
|
15
|
+
return `Invalid value for \`${source}\`: ${JSON.stringify(value)}. Expected one of: ${types_1.CRED_STORAGE_CONFIG_VALUES.map(storage => JSON.stringify(storage)).join(', ')}.`;
|
|
16
|
+
}
|
|
17
|
+
function parseCredStorage(value, source = 'credStorage') {
|
|
18
|
+
if (typeof value === 'undefined') {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
if (isCredStorage(value)) {
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
throw new Error(formatCredStorageError(value, source));
|
|
25
|
+
}
|
|
26
|
+
function authConfigHasUsableTokenData(value) {
|
|
27
|
+
if (!value || typeof value !== 'object') {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
const authConfig = value;
|
|
31
|
+
return ((typeof authConfig.token === 'string' && authConfig.token.length > 0) ||
|
|
32
|
+
(typeof authConfig.refreshToken === 'string' &&
|
|
33
|
+
authConfig.refreshToken.length > 0));
|
|
34
|
+
}
|
|
35
|
+
function getLikelyAutoCredStorage(configDir) {
|
|
36
|
+
try {
|
|
37
|
+
return authConfigHasUsableTokenData((0, cli_config_1.readAuthConfigFile)((0, cli_config_1.getAuthConfigFilePath)(configDir)))
|
|
38
|
+
? 'file'
|
|
39
|
+
: 'keyring';
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return 'keyring';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function getLikelyConfiguredCredStorage(configDir, credStorage) {
|
|
46
|
+
if (credStorage === 'keyring') {
|
|
47
|
+
return 'keyring';
|
|
48
|
+
}
|
|
49
|
+
if (credStorage !== 'auto') {
|
|
50
|
+
return types_1.DEFAULT_CRED_STORAGE;
|
|
51
|
+
}
|
|
52
|
+
return getLikelyAutoCredStorage(configDir);
|
|
53
|
+
}
|
|
54
|
+
function getLikelyEffectiveCredStorage(configDir) {
|
|
55
|
+
let config = {};
|
|
56
|
+
const credStorageOverride = process.env[TOKEN_STORAGE_ENV];
|
|
57
|
+
if (typeof credStorageOverride !== 'undefined') {
|
|
58
|
+
return getLikelyConfiguredCredStorage(configDir, parseCredStorage(credStorageOverride, TOKEN_STORAGE_ENV));
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
const parsed = (0, cli_config_1.readGlobalConfigFile)((0, cli_config_1.getConfigFilePath)(configDir));
|
|
62
|
+
config = {
|
|
63
|
+
...parsed,
|
|
64
|
+
credStorage: parseCredStorage(parsed.credStorage),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
if (!(isErrnoException(error) && error.code === 'ENOENT')) {
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return getLikelyConfiguredCredStorage(configDir, config.credStorage);
|
|
73
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/paths.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function getGlobalPathConfig(): string;
|
|
2
|
+
export declare function getConfigFilePath(configDir: string): string;
|
|
3
|
+
export declare function getAuthConfigFilePath(configDir: string): string;
|
|
4
|
+
export declare function readGlobalConfigFlag(configPath: string, key: string): unknown;
|
package/dist/paths.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getGlobalPathConfig = getGlobalPathConfig;
|
|
7
|
+
exports.getConfigFilePath = getConfigFilePath;
|
|
8
|
+
exports.getAuthConfigFilePath = getAuthConfigFilePath;
|
|
9
|
+
exports.readGlobalConfigFlag = readGlobalConfigFlag;
|
|
10
|
+
// Zod-free path helpers so hot paths (e.g. the `vc.js` shim) can locate and
|
|
11
|
+
// read the global config without loading zod and the config schemas.
|
|
12
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
13
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
14
|
+
const node_os_1 = require("node:os");
|
|
15
|
+
const xdg_app_paths_1 = __importDefault(require("xdg-app-paths"));
|
|
16
|
+
function isReadableDirectory(targetPath) {
|
|
17
|
+
try {
|
|
18
|
+
return node_fs_1.default.lstatSync(targetPath).isDirectory();
|
|
19
|
+
}
|
|
20
|
+
catch (_) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function getGlobalPathConfig() {
|
|
25
|
+
const vercelDirectories = (0, xdg_app_paths_1.default)('com.vercel.cli').dataDirs();
|
|
26
|
+
const possibleConfigPaths = [
|
|
27
|
+
...vercelDirectories, // latest vercel directory
|
|
28
|
+
node_path_1.default.join((0, node_os_1.homedir)(), '.now'), // legacy config in user's home directory
|
|
29
|
+
...(0, xdg_app_paths_1.default)('now').dataDirs(), // legacy XDG directory
|
|
30
|
+
];
|
|
31
|
+
return (possibleConfigPaths.find(configPath => isReadableDirectory(configPath)) ||
|
|
32
|
+
vercelDirectories[0]);
|
|
33
|
+
}
|
|
34
|
+
function getConfigFilePath(configDir) {
|
|
35
|
+
return node_path_1.default.join(configDir, 'config.json');
|
|
36
|
+
}
|
|
37
|
+
function getAuthConfigFilePath(configDir) {
|
|
38
|
+
return node_path_1.default.join(configDir, 'auth.json');
|
|
39
|
+
}
|
|
40
|
+
// Reads a single key from the global config file without schema validation,
|
|
41
|
+
// for cheap feature-gate reads on hot paths.
|
|
42
|
+
function readGlobalConfigFlag(configPath, key) {
|
|
43
|
+
try {
|
|
44
|
+
const content = node_fs_1.default.readFileSync(configPath, 'utf8').replace(/^\uFEFF/, '');
|
|
45
|
+
const parsed = JSON.parse(content);
|
|
46
|
+
if (parsed && typeof parsed === 'object') {
|
|
47
|
+
return parsed[key];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
// Missing/unreadable/invalid config is treated as "no value".
|
|
52
|
+
}
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
package/dist/schema.d.ts
CHANGED
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
* Schemas are generated by ts-to-zod and re-exported here with runtime
|
|
6
6
|
* passthrough behavior for unrecognized config keys.
|
|
7
7
|
*/
|
|
8
|
-
import
|
|
9
|
-
import type { AuthConfig, GlobalConfig, GuidanceConfig, TelemetryConfig, UpdatesConfig } from './types';
|
|
8
|
+
import { z } from 'zod';
|
|
9
|
+
import type { AuthConfig, CredStorage, GlobalConfig, GuidanceConfig, TelemetryConfig, UpdatesConfig } from './types';
|
|
10
10
|
export declare const telemetryConfigSchema: z.ZodType<TelemetryConfig>;
|
|
11
11
|
export declare const guidanceConfigSchema: z.ZodType<GuidanceConfig>;
|
|
12
12
|
export declare const updatesConfigSchema: z.ZodType<UpdatesConfig>;
|
|
13
|
+
export declare const credStorageSchema: z.ZodType<CredStorage | undefined>;
|
|
13
14
|
export declare const globalConfigSchema: z.ZodType<GlobalConfig>;
|
|
14
15
|
export declare const authConfigSchema: z.ZodType<AuthConfig>;
|
package/dist/schema.js
CHANGED
|
@@ -7,13 +7,26 @@
|
|
|
7
7
|
* passthrough behavior for unrecognized config keys.
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.authConfigSchema = exports.globalConfigSchema = exports.updatesConfigSchema = exports.guidanceConfigSchema = exports.telemetryConfigSchema = void 0;
|
|
10
|
+
exports.authConfigSchema = exports.globalConfigSchema = exports.credStorageSchema = exports.updatesConfigSchema = exports.guidanceConfigSchema = exports.telemetryConfigSchema = void 0;
|
|
11
|
+
const zod_1 = require("zod");
|
|
11
12
|
const schema_zod_1 = require("./schema.zod");
|
|
13
|
+
const types_1 = require("./types");
|
|
14
|
+
function formatCredStorageError(value) {
|
|
15
|
+
return `Invalid value for \`credStorage\`: ${JSON.stringify(value)}. Expected one of: ${types_1.CRED_STORAGE_CONFIG_VALUES.map(storage => JSON.stringify(storage)).join(', ')}.`;
|
|
16
|
+
}
|
|
12
17
|
exports.telemetryConfigSchema = schema_zod_1.telemetryConfigSchema.passthrough();
|
|
13
18
|
exports.guidanceConfigSchema = schema_zod_1.guidanceConfigSchema.passthrough();
|
|
14
19
|
exports.updatesConfigSchema = schema_zod_1.updatesConfigSchema.passthrough();
|
|
20
|
+
exports.credStorageSchema = zod_1.z
|
|
21
|
+
.enum(types_1.CRED_STORAGE_CONFIG_VALUES, {
|
|
22
|
+
error: issue => {
|
|
23
|
+
return formatCredStorageError(issue.input);
|
|
24
|
+
},
|
|
25
|
+
})
|
|
26
|
+
.optional();
|
|
15
27
|
exports.globalConfigSchema = schema_zod_1.globalConfigSchema
|
|
16
28
|
.extend({
|
|
29
|
+
credStorage: exports.credStorageSchema,
|
|
17
30
|
telemetry: exports.telemetryConfigSchema.optional(),
|
|
18
31
|
guidance: exports.guidanceConfigSchema.optional(),
|
|
19
32
|
updates: exports.updatesConfigSchema.optional(),
|
package/dist/schema.zod.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export declare const guidanceConfigSchema: z.ZodObject<{
|
|
|
8
8
|
export declare const updatesConfigSchema: z.ZodObject<{
|
|
9
9
|
auto: z.ZodOptional<z.ZodBoolean>;
|
|
10
10
|
}, z.core.$strip>;
|
|
11
|
+
export declare const credStorageSchema: z.ZodUnion<readonly [z.ZodLiteral<"auto">, z.ZodLiteral<"file">, z.ZodLiteral<"keyring">]>;
|
|
11
12
|
export declare const authConfigSchema: z.ZodObject<{
|
|
12
13
|
'// Note': z.ZodOptional<z.ZodString>;
|
|
13
14
|
'// Docs': z.ZodOptional<z.ZodString>;
|
|
@@ -18,9 +19,19 @@ export declare const authConfigSchema: z.ZodObject<{
|
|
|
18
19
|
expiresAt: z.ZodOptional<z.ZodNumber>;
|
|
19
20
|
tokenSource: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"flag">, z.ZodLiteral<"env">]>>;
|
|
20
21
|
}, z.core.$strip>;
|
|
22
|
+
export declare const authFileConfigSchema: z.ZodObject<{
|
|
23
|
+
'// Note': z.ZodOptional<z.ZodString>;
|
|
24
|
+
'// Docs': z.ZodOptional<z.ZodString>;
|
|
25
|
+
skipWrite: z.ZodOptional<z.ZodBoolean>;
|
|
26
|
+
token: z.ZodOptional<z.ZodString>;
|
|
27
|
+
userId: z.ZodOptional<z.ZodString>;
|
|
28
|
+
refreshToken: z.ZodOptional<z.ZodString>;
|
|
29
|
+
expiresAt: z.ZodOptional<z.ZodNumber>;
|
|
30
|
+
}, z.core.$strip>;
|
|
21
31
|
export declare const globalConfigSchema: z.ZodObject<{
|
|
22
32
|
'// Note': z.ZodOptional<z.ZodString>;
|
|
23
33
|
'// Docs': z.ZodOptional<z.ZodString>;
|
|
34
|
+
credStorage: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"auto">, z.ZodLiteral<"file">, z.ZodLiteral<"keyring">]>>;
|
|
24
35
|
currentTeam: z.ZodOptional<z.ZodString>;
|
|
25
36
|
api: z.ZodOptional<z.ZodString>;
|
|
26
37
|
telemetry: z.ZodOptional<z.ZodObject<{
|
|
@@ -32,4 +43,5 @@ export declare const globalConfigSchema: z.ZodObject<{
|
|
|
32
43
|
updates: z.ZodOptional<z.ZodObject<{
|
|
33
44
|
auto: z.ZodOptional<z.ZodBoolean>;
|
|
34
45
|
}, z.core.$strip>>;
|
|
46
|
+
useNativeBinary: z.ZodOptional<z.ZodBoolean>;
|
|
35
47
|
}, z.core.$strip>;
|
package/dist/schema.zod.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.globalConfigSchema = exports.authConfigSchema = exports.updatesConfigSchema = exports.guidanceConfigSchema = exports.telemetryConfigSchema = void 0;
|
|
3
|
+
exports.globalConfigSchema = exports.authFileConfigSchema = exports.authConfigSchema = exports.credStorageSchema = exports.updatesConfigSchema = exports.guidanceConfigSchema = exports.telemetryConfigSchema = void 0;
|
|
4
4
|
// Generated by ts-to-zod
|
|
5
5
|
const zod_1 = require("zod");
|
|
6
6
|
exports.telemetryConfigSchema = zod_1.z.object({
|
|
@@ -12,6 +12,11 @@ exports.guidanceConfigSchema = zod_1.z.object({
|
|
|
12
12
|
exports.updatesConfigSchema = zod_1.z.object({
|
|
13
13
|
auto: zod_1.z.boolean().optional(),
|
|
14
14
|
});
|
|
15
|
+
exports.credStorageSchema = zod_1.z.union([
|
|
16
|
+
zod_1.z.literal('auto'),
|
|
17
|
+
zod_1.z.literal('file'),
|
|
18
|
+
zod_1.z.literal('keyring'),
|
|
19
|
+
]);
|
|
15
20
|
exports.authConfigSchema = zod_1.z.object({
|
|
16
21
|
'// Note': zod_1.z.string().optional(),
|
|
17
22
|
'// Docs': zod_1.z.string().optional(),
|
|
@@ -22,12 +27,17 @@ exports.authConfigSchema = zod_1.z.object({
|
|
|
22
27
|
expiresAt: zod_1.z.number().optional(),
|
|
23
28
|
tokenSource: zod_1.z.union([zod_1.z.literal('flag'), zod_1.z.literal('env')]).optional(),
|
|
24
29
|
});
|
|
30
|
+
exports.authFileConfigSchema = exports.authConfigSchema.omit({
|
|
31
|
+
tokenSource: true,
|
|
32
|
+
});
|
|
25
33
|
exports.globalConfigSchema = zod_1.z.object({
|
|
26
34
|
'// Note': zod_1.z.string().optional(),
|
|
27
35
|
'// Docs': zod_1.z.string().optional(),
|
|
36
|
+
credStorage: exports.credStorageSchema.optional(),
|
|
28
37
|
currentTeam: zod_1.z.string().optional(),
|
|
29
38
|
api: zod_1.z.string().optional(),
|
|
30
39
|
telemetry: exports.telemetryConfigSchema.optional(),
|
|
31
40
|
guidance: exports.guidanceConfigSchema.optional(),
|
|
32
41
|
updates: exports.updatesConfigSchema.optional(),
|
|
42
|
+
useNativeBinary: zod_1.z.boolean().optional(),
|
|
33
43
|
});
|
package/dist/types.d.ts
CHANGED
|
@@ -13,6 +13,11 @@ export interface GuidanceConfig {
|
|
|
13
13
|
export interface UpdatesConfig {
|
|
14
14
|
auto?: boolean;
|
|
15
15
|
}
|
|
16
|
+
export type CredStorage = 'auto' | 'file' | 'keyring';
|
|
17
|
+
export type CredentialsStorageLocation = Exclude<CredStorage, 'auto'>;
|
|
18
|
+
export declare const CRED_STORAGE_CONFIG_VALUES: readonly ["auto", "file", "keyring"];
|
|
19
|
+
export declare const CRED_STORAGE_VALUES: ("file" | "keyring")[];
|
|
20
|
+
export declare const DEFAULT_CRED_STORAGE: CredentialsStorageLocation;
|
|
16
21
|
export interface AuthConfig {
|
|
17
22
|
'// Note'?: string;
|
|
18
23
|
'// Docs'?: string;
|
|
@@ -23,12 +28,16 @@ export interface AuthConfig {
|
|
|
23
28
|
expiresAt?: number;
|
|
24
29
|
tokenSource?: 'flag' | 'env';
|
|
25
30
|
}
|
|
31
|
+
export type AuthFileConfig = Omit<AuthConfig, 'tokenSource'>;
|
|
26
32
|
export interface GlobalConfig {
|
|
27
33
|
'// Note'?: string;
|
|
28
34
|
'// Docs'?: string;
|
|
35
|
+
credStorage?: CredStorage;
|
|
29
36
|
currentTeam?: string;
|
|
30
37
|
api?: string;
|
|
31
38
|
telemetry?: TelemetryConfig;
|
|
32
39
|
guidance?: GuidanceConfig;
|
|
33
40
|
updates?: UpdatesConfig;
|
|
41
|
+
/** Opt-in to running the native Vercel CLI binary when one is installed. */
|
|
42
|
+
useNativeBinary?: boolean;
|
|
34
43
|
}
|
package/dist/types.js
CHANGED
|
@@ -6,3 +6,11 @@
|
|
|
6
6
|
* Zod schemas are generated from these using ts-to-zod.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.DEFAULT_CRED_STORAGE = exports.CRED_STORAGE_VALUES = exports.CRED_STORAGE_CONFIG_VALUES = void 0;
|
|
10
|
+
exports.CRED_STORAGE_CONFIG_VALUES = [
|
|
11
|
+
'auto',
|
|
12
|
+
'file',
|
|
13
|
+
'keyring',
|
|
14
|
+
];
|
|
15
|
+
exports.CRED_STORAGE_VALUES = exports.CRED_STORAGE_CONFIG_VALUES.filter((storage) => storage !== 'auto');
|
|
16
|
+
exports.DEFAULT_CRED_STORAGE = 'file';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/cli-config",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Shared core utilities for Vercel global configuration",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://vercel.com/docs/projects/project-configuration/global-configuration",
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"main": "dist/index.js",
|
|
13
13
|
"types": "dist/index.d.ts",
|
|
14
14
|
"exports": {
|
|
15
|
-
".": "./dist/index.js"
|
|
15
|
+
".": "./dist/index.js",
|
|
16
|
+
"./paths": "./dist/paths.js"
|
|
16
17
|
},
|
|
17
18
|
"private": false,
|
|
18
19
|
"files": [
|