netlify-cli 17.23.6 → 17.23.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/dist/commands/env/env-get.d.ts.map +1 -1
- package/dist/commands/env/env-get.js +0 -1
- package/dist/commands/functions/functions-create.d.ts.map +1 -1
- package/dist/commands/functions/functions-create.js +1 -5
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/copy-template-dir/copy-template-dir.d.ts +2 -0
- package/dist/utils/copy-template-dir/copy-template-dir.d.ts.map +1 -0
- package/dist/utils/copy-template-dir/copy-template-dir.js +74 -0
- package/dist/utils/env/index.d.ts +6 -5
- package/dist/utils/env/index.d.ts.map +1 -1
- package/dist/utils/env/index.js +4 -18
- package/npm-shrinkwrap.json +24 -2180
- package/package.json +4 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copy-template-dir.d.ts","sourceRoot":"","sources":["../../../src/utils/copy-template-dir/copy-template-dir.ts"],"names":[],"mappings":"AA0DA,wBAAsB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAiClG"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// License for copy-template-dir.
|
|
2
|
+
// Original repository: https://github.com/yoshuawuyts/copy-template-dir
|
|
3
|
+
// The MIT License (MIT)
|
|
4
|
+
// Copyright (c) 2015 Yoshua Wuyts
|
|
5
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
|
6
|
+
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
|
7
|
+
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
8
|
+
// persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
9
|
+
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
|
10
|
+
// Software.
|
|
11
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
|
12
|
+
// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
13
|
+
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
14
|
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
15
|
+
import assert from 'assert';
|
|
16
|
+
import fs from 'fs';
|
|
17
|
+
import path from 'path';
|
|
18
|
+
import { pipeline } from 'stream';
|
|
19
|
+
import { promisify } from 'util';
|
|
20
|
+
// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'maxstache... Remove this comment to see the full error message
|
|
21
|
+
import maxstache from 'maxstache';
|
|
22
|
+
// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'maxstache-stream... Remove this comment to see the full error message
|
|
23
|
+
import maxstacheStream from 'maxstache-stream';
|
|
24
|
+
import readdirp from 'readdirp';
|
|
25
|
+
const noop = () => undefined;
|
|
26
|
+
// Remove a leading underscore
|
|
27
|
+
function removeUnderscore(filepath) {
|
|
28
|
+
const parts = filepath.split(path.sep);
|
|
29
|
+
const filename = parts.pop()?.replace(/^_/, '') || '';
|
|
30
|
+
return [...parts, filename].join(path.sep);
|
|
31
|
+
}
|
|
32
|
+
// Write a file to a directory
|
|
33
|
+
async function writeFile(outDir, vars, file) {
|
|
34
|
+
const fileName = file.path;
|
|
35
|
+
const inFile = file.fullPath;
|
|
36
|
+
const parentDir = path.dirname(file.path);
|
|
37
|
+
const outFile = path.join(outDir, maxstache(removeUnderscore(fileName), vars));
|
|
38
|
+
await fs.promises.mkdir(path.join(outDir, maxstache(parentDir, vars)), { recursive: true });
|
|
39
|
+
const rs = fs.createReadStream(inFile);
|
|
40
|
+
const ts = maxstacheStream(vars);
|
|
41
|
+
const ws = fs.createWriteStream(outFile);
|
|
42
|
+
await promisify(pipeline)(rs, ts, ws);
|
|
43
|
+
}
|
|
44
|
+
// High throughput template dir writes
|
|
45
|
+
export async function copyTemplateDir(srcDir, outDir, vars) {
|
|
46
|
+
if (!vars)
|
|
47
|
+
vars = noop;
|
|
48
|
+
assert.strictEqual(typeof srcDir, 'string');
|
|
49
|
+
assert.strictEqual(typeof outDir, 'string');
|
|
50
|
+
assert.strictEqual(typeof vars, 'object');
|
|
51
|
+
await fs.promises.mkdir(outDir, { recursive: true });
|
|
52
|
+
const rs = readdirp(srcDir);
|
|
53
|
+
const streams = [];
|
|
54
|
+
const createdFiles = [];
|
|
55
|
+
rs.on('data', (file) => {
|
|
56
|
+
createdFiles.push(path.join(outDir, maxstache(removeUnderscore(file.path), vars)));
|
|
57
|
+
streams.push(writeFile(outDir, vars, file));
|
|
58
|
+
});
|
|
59
|
+
await new Promise((resolve, reject) => {
|
|
60
|
+
rs.on('end', async () => {
|
|
61
|
+
try {
|
|
62
|
+
await Promise.all(streams);
|
|
63
|
+
resolve();
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
reject(error);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
rs.on('error', (error) => {
|
|
70
|
+
reject(error);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
return createdFiles;
|
|
74
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { $TSFixMe } from '../../commands/types.js';
|
|
1
2
|
export declare const AVAILABLE_CONTEXTS: string[];
|
|
2
3
|
export declare const AVAILABLE_SCOPES: string[];
|
|
3
4
|
/**
|
|
@@ -44,12 +45,12 @@ export declare const filterEnvBySource: (env: any, source: any) => {
|
|
|
44
45
|
* },
|
|
45
46
|
* }
|
|
46
47
|
*/
|
|
47
|
-
export declare const formatEnvelopeData: ({ context, envelopeItems, scope, source }: {
|
|
48
|
+
export declare const formatEnvelopeData: ({ context, envelopeItems, scope, source, }: {
|
|
48
49
|
context?: string | undefined;
|
|
49
|
-
envelopeItems
|
|
50
|
+
envelopeItems: $TSFixMe[];
|
|
50
51
|
scope?: string | undefined;
|
|
51
|
-
source:
|
|
52
|
-
}) =>
|
|
52
|
+
source: string;
|
|
53
|
+
}) => any;
|
|
53
54
|
/**
|
|
54
55
|
* Collects env vars from multiple sources and arranges them in the correct order of precedence
|
|
55
56
|
* @param {object} api - The api singleton object
|
|
@@ -69,7 +70,7 @@ export declare const getEnvelopeEnv: ({ api, context, env, key, raw, scope, site
|
|
|
69
70
|
raw?: boolean | undefined;
|
|
70
71
|
scope?: string | undefined;
|
|
71
72
|
siteInfo: any;
|
|
72
|
-
}) => Promise<
|
|
73
|
+
}) => Promise<any>;
|
|
73
74
|
/**
|
|
74
75
|
* Returns a human-readable, comma-separated list of scopes
|
|
75
76
|
* @param {Array<enum<builds,functions,runtime,post_processing>>} scopes - An array of scopes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/env/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/env/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAGlD,eAAO,MAAM,kBAAkB,UAAkE,CAAA;AACjG,eAAO,MAAM,gBAAgB,UAAwD,CAAA;AAErF;;;GAGG;AAEH,eAAO,MAAM,gBAAgB,uBAmB5B,CAAA;AAED;;;;;GAKG;AAEH,eAAO,MAAM,iBAAiB,oCAQ1B,CAAA;AAEJ;;;;;GAKG;AAEH,eAAO,MAAM,iBAAiB;;CAEoE,CAAA;AAiClG;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,kBAAkB;;mBAOd,QAAQ,EAAE;;YAEjB,MAAM;SAsBN,CAAA;AAEV;;;;;;;;;;GAUG;AAEH,eAAO,MAAM,cAAc;;;;;;;;kBAyC1B,CAAA;AAED;;;;GAIG;AAEH,eAAO,MAAM,sBAAsB,sBAoBlC,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,4BAA4B;;;;;;;GAaxC,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,6CAe/B,CAAA"}
|
package/dist/utils/env/index.js
CHANGED
|
@@ -52,18 +52,10 @@ values.find((val) => {
|
|
|
52
52
|
export const filterEnvBySource = (env, source) =>
|
|
53
53
|
// @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
|
|
54
54
|
Object.fromEntries(Object.entries(env).filter(([, variable]) => variable.sources[0] === source));
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
* @param {string} accountId - The account id
|
|
58
|
-
* @param {object} api - The api singleton object
|
|
59
|
-
* @param {string} key - If present, fetch a single key (case-sensitive)
|
|
60
|
-
* @param {string} siteId - The site id
|
|
61
|
-
* @returns {Array<object>} An array of environment variables from the Envelope service
|
|
62
|
-
*/
|
|
63
|
-
// @ts-expect-error TS(7031) FIXME: Binding element 'accountId' implicitly has an 'any... Remove this comment to see the full error message
|
|
64
|
-
const fetchEnvelopeItems = async function ({ accountId, api, key, siteId }) {
|
|
55
|
+
// Fetches data from Envelope
|
|
56
|
+
const fetchEnvelopeItems = async function ({ accountId, api, key, siteId, }) {
|
|
65
57
|
if (accountId === undefined) {
|
|
66
|
-
return
|
|
58
|
+
return [];
|
|
67
59
|
}
|
|
68
60
|
try {
|
|
69
61
|
// if a single key is passed, fetch that single env var
|
|
@@ -104,27 +96,21 @@ const fetchEnvelopeItems = async function ({ accountId, api, key, siteId }) {
|
|
|
104
96
|
* },
|
|
105
97
|
* }
|
|
106
98
|
*/
|
|
107
|
-
|
|
108
|
-
export const formatEnvelopeData = ({ context = 'dev', envelopeItems = [], scope = 'any', source }) => envelopeItems
|
|
99
|
+
export const formatEnvelopeData = ({ context = 'dev', envelopeItems = [], scope = 'any', source, }) => envelopeItems
|
|
109
100
|
// filter by context
|
|
110
101
|
.filter(({ values }) => Boolean(findValueInValues(values, context)))
|
|
111
102
|
// filter by scope
|
|
112
|
-
// @ts-expect-error TS(2339) FIXME: Property 'includes' does not exist on type 'never'... Remove this comment to see the full error message
|
|
113
103
|
.filter(({ scopes }) => (scope === 'any' ? true : scopes.includes(scope)))
|
|
114
104
|
// sort alphabetically, case insensitive
|
|
115
|
-
// @ts-expect-error TS(2339) FIXME: Property 'key' does not exist on type 'never'.
|
|
116
105
|
.sort((left, right) => (left.key.toLowerCase() < right.key.toLowerCase() ? -1 : 1))
|
|
117
106
|
// format the data
|
|
118
107
|
.reduce((acc, cur) => {
|
|
119
|
-
// @ts-expect-error TS(2339) FIXME: Property 'values' does not exist on type 'never'.
|
|
120
108
|
const { context: ctx, context_parameter: branch, value } = findValueInValues(cur.values, context);
|
|
121
109
|
return {
|
|
122
110
|
...acc,
|
|
123
|
-
// @ts-expect-error TS(2339) FIXME: Property 'key' does not exist on type 'never'.
|
|
124
111
|
[cur.key]: {
|
|
125
112
|
context: ctx,
|
|
126
113
|
branch,
|
|
127
|
-
// @ts-expect-error TS(2339) FIXME: Property 'scopes' does not exist on type 'never'.
|
|
128
114
|
scopes: cur.scopes,
|
|
129
115
|
sources: [source],
|
|
130
116
|
value,
|