zapier-platform-cli 17.1.0 → 17.3.0
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/oclif.manifest.json +6 -8
- package/package.json +3 -5
- package/src/constants.js +3 -10
- package/src/oclif/commands/build.js +13 -5
- package/src/oclif/commands/deprecate.js +3 -3
- package/src/oclif/commands/push.js +9 -1
- package/src/utils/build.js +513 -296
- package/src/utils/files.js +41 -7
- package/src/utils/ignore.js +29 -9
- package/src/utils/itertools.js +39 -0
- package/src/utils/misc.js +5 -4
package/src/utils/files.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const os = require('os');
|
|
4
|
-
const path = require('path');
|
|
1
|
+
const crypto = require('node:crypto');
|
|
2
|
+
const fs = require('node:fs');
|
|
3
|
+
const os = require('node:os');
|
|
4
|
+
const path = require('node:path');
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const _ = require('lodash');
|
|
7
7
|
const colors = require('colors/safe');
|
|
8
|
+
const fse = require('fs-extra');
|
|
8
9
|
|
|
9
10
|
const fixHome = (dir) => {
|
|
10
11
|
const home = process.env.HOME || process.env.USERPROFILE;
|
|
@@ -200,19 +201,52 @@ const makeTempDir = () => {
|
|
|
200
201
|
return workdir;
|
|
201
202
|
};
|
|
202
203
|
|
|
204
|
+
// Iterates files and symlinks in a directory recursively.
|
|
205
|
+
// Yields fs.Dirent objects.
|
|
206
|
+
function* walkDir(dir) {
|
|
207
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
208
|
+
for (const entry of entries) {
|
|
209
|
+
if (entry.isDirectory()) {
|
|
210
|
+
const subDir = path.join(entry.parentPath, entry.name);
|
|
211
|
+
yield* walkDir(subDir);
|
|
212
|
+
} else if (entry.isFile() || entry.isSymbolicLink()) {
|
|
213
|
+
yield entry;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// Iterates files and symlinks in a directory recursively, up to a specified
|
|
219
|
+
// number of levels deep (maxLevels). The minimum value for maxLevels is 1.
|
|
220
|
+
// Yields fs.Dirent objects.
|
|
221
|
+
function* walkDirLimitedLevels(dir, maxLevels, currentLevel = 1) {
|
|
222
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
223
|
+
for (const entry of entries) {
|
|
224
|
+
if (entry.isDirectory()) {
|
|
225
|
+
if (currentLevel < maxLevels) {
|
|
226
|
+
const subDir = path.join(entry.parentPath, entry.name);
|
|
227
|
+
yield* walkDirLimitedLevels(subDir, maxLevels, currentLevel + 1);
|
|
228
|
+
}
|
|
229
|
+
} else if (entry.isFile() || entry.isSymbolicLink()) {
|
|
230
|
+
yield entry;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
203
235
|
module.exports = {
|
|
204
236
|
copyDir,
|
|
237
|
+
copyFile,
|
|
205
238
|
deleteFile,
|
|
206
239
|
ensureDir,
|
|
207
240
|
fileExistsSync,
|
|
208
241
|
isEmptyDir,
|
|
209
242
|
isExistingEmptyDir,
|
|
243
|
+
makeTempDir,
|
|
210
244
|
readFile,
|
|
211
245
|
readFileStr,
|
|
212
246
|
removeDir,
|
|
213
247
|
removeDirSync,
|
|
214
248
|
validateFileExists,
|
|
249
|
+
walkDir,
|
|
250
|
+
walkDirLimitedLevels,
|
|
215
251
|
writeFile,
|
|
216
|
-
copyFile,
|
|
217
|
-
makeTempDir,
|
|
218
252
|
};
|
package/src/utils/ignore.js
CHANGED
|
@@ -1,20 +1,40 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
1
|
+
const fs = require('node:fs');
|
|
2
|
+
const path = require('node:path');
|
|
3
|
+
|
|
2
4
|
const colors = require('colors/safe');
|
|
3
|
-
const ignore = require('ignore');
|
|
4
5
|
const gitIgnore = require('parse-gitignore');
|
|
5
|
-
const
|
|
6
|
+
const ignore = require('ignore');
|
|
7
|
+
|
|
8
|
+
const { IS_TESTING } = require('../constants');
|
|
9
|
+
|
|
10
|
+
const BLOCKLISTED_PREFIXES = [
|
|
11
|
+
'.DS_Store',
|
|
12
|
+
`.git${path.sep}`,
|
|
13
|
+
`build${path.sep}`,
|
|
14
|
+
];
|
|
15
|
+
const BLOCKLISTED_SUFFIXES = ['.gitkeep', '.env', '.environment', '.zip'];
|
|
6
16
|
|
|
7
|
-
|
|
8
|
-
const isBlocklisted = (
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
17
|
+
// Tells if we should exclude a file from build.zip or source.zip
|
|
18
|
+
const isBlocklisted = (relPath) => {
|
|
19
|
+
// Will be excluded from build.zip and source.zip
|
|
20
|
+
for (const prefix of BLOCKLISTED_PREFIXES) {
|
|
21
|
+
if (relPath.startsWith(prefix)) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
for (const suffix of BLOCKLISTED_SUFFIXES) {
|
|
26
|
+
if (relPath.endsWith(suffix)) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return false;
|
|
12
31
|
};
|
|
32
|
+
|
|
13
33
|
// Exclude file paths in .gitignore
|
|
14
34
|
const respectGitIgnore = (dir, paths) => {
|
|
15
35
|
const gitIgnorePath = path.join(dir, '.gitignore');
|
|
16
36
|
if (!fs.existsSync(gitIgnorePath)) {
|
|
17
|
-
if (!
|
|
37
|
+
if (!IS_TESTING) {
|
|
18
38
|
console.warn(
|
|
19
39
|
`\n\n\t${colors.yellow(
|
|
20
40
|
'!! Warning !!',
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// This module provides convenience functions for working with Generators:
|
|
2
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator
|
|
3
|
+
|
|
4
|
+
// Filters an iterable using a predicate function. Example:
|
|
5
|
+
//
|
|
6
|
+
// const isEven = (x) => x % 2 === 0;
|
|
7
|
+
// function* generateNumbers() {
|
|
8
|
+
// for (let i = 0; i < 100; i++) {
|
|
9
|
+
// yield i;
|
|
10
|
+
// }
|
|
11
|
+
// }
|
|
12
|
+
// const generateEvenNumbers = iterfilter(isEven, generateNumbers());
|
|
13
|
+
function* iterfilter(predicate, iterable) {
|
|
14
|
+
for (const item of iterable) {
|
|
15
|
+
if (predicate(item)) {
|
|
16
|
+
yield item;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Maps an iterable using a function, like Array.prototype.map. Example:
|
|
22
|
+
//
|
|
23
|
+
// const double = (x) => x * 2;
|
|
24
|
+
// function* generateNumbers() {
|
|
25
|
+
// for (let i = 0; i < 100; i++) {
|
|
26
|
+
// yield i;
|
|
27
|
+
// }
|
|
28
|
+
// }
|
|
29
|
+
// const generateDoubledNumbers = itermap(double, generateNumbers());
|
|
30
|
+
function* itermap(fn, iterable) {
|
|
31
|
+
for (const item of iterable) {
|
|
32
|
+
yield fn(item);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
module.exports = {
|
|
37
|
+
iterfilter,
|
|
38
|
+
itermap,
|
|
39
|
+
};
|
package/src/utils/misc.js
CHANGED
|
@@ -69,10 +69,11 @@ const runCommand = (command, args, options) => {
|
|
|
69
69
|
result.on('error', reject);
|
|
70
70
|
|
|
71
71
|
result.on('close', (code) => {
|
|
72
|
-
if (code
|
|
72
|
+
if (code === 0) {
|
|
73
|
+
resolve({ stdout, stderr });
|
|
74
|
+
} else {
|
|
73
75
|
reject(new Error(stderr));
|
|
74
76
|
}
|
|
75
|
-
resolve({ stdout, stderr });
|
|
76
77
|
});
|
|
77
78
|
});
|
|
78
79
|
};
|
|
@@ -80,8 +81,8 @@ const runCommand = (command, args, options) => {
|
|
|
80
81
|
const isValidNodeVersion = (version = process.version) =>
|
|
81
82
|
semver.satisfies(version, NODE_VERSION_CLI_REQUIRES);
|
|
82
83
|
|
|
83
|
-
const findCorePackageDir = () => {
|
|
84
|
-
let baseDir = process.cwd();
|
|
84
|
+
const findCorePackageDir = (workingDir) => {
|
|
85
|
+
let baseDir = workingDir || process.cwd();
|
|
85
86
|
// 500 is just an arbitrary number to prevent infinite loops
|
|
86
87
|
for (let i = 0; i < 500; i++) {
|
|
87
88
|
const dir = path.join(baseDir, 'node_modules', PLATFORM_PACKAGE);
|