multi-clasp2 2.1.0 → 3.0.2
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/README.md +13 -4
- package/build/common.js +94 -0
- package/build/common.js.map +1 -0
- package/build/{src/config.js → config.js} +0 -0
- package/build/config.js.map +1 -0
- package/build/index.js +57 -0
- package/build/index.js.map +1 -0
- package/build/mutli-clasp-errors.js +12 -0
- package/build/mutli-clasp-errors.js.map +1 -0
- package/build/push.js +48 -0
- package/build/push.js.map +1 -0
- package/build/run.js +49 -0
- package/build/run.js.map +1 -0
- package/build/utils.js +45 -0
- package/build/utils.js.map +1 -0
- package/package.json +10 -8
- package/build/src/common.js +0 -46
- package/build/src/common.js.map +0 -1
- package/build/src/config.js.map +0 -1
- package/build/src/index.js +0 -40
- package/build/src/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -33,10 +33,19 @@ You do not need a .clasp.json file anymore.
|
|
|
33
33
|
]
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
## Commands
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
The following clasp commands are supported. For the documentation refer to the official [documentation](https://github.com/google/clasp)
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
- [`mutli-clasp push [--force --retry <n>]`](https://github.com/google/clasp#push) <br>
|
|
41
|
+
in addition to the clasp arguments there is the --retry option: If the push of an App Script fail with it will retry times. Default is 1.
|
|
42
|
+
|
|
43
|
+
- [`mutli-clasp status [--json]`](https://github.com/google/clasp#status)
|
|
44
|
+
- [`mutli-clasp open [--webapp] [--creds] [--addon]`](https://github.com/google/clasp#open)
|
|
45
|
+
- [`mutli-clasp deployments`](https://github.com/google/clasp#deployments)
|
|
46
|
+
- [`mutli-clasp deploy [--versionNumber <version>] [--description <description>]`](https://github.com/google/clasp#deploy)
|
|
47
|
+
- [`mutli-clasp undeploy [--all]`](https://github.com/google/clasp#undeploy)
|
|
48
|
+
- [`mutli-clasp version [description]`](https://github.com/google/clasp#version)
|
|
49
|
+
- [`mutli-clasp versions`](https://github.com/google/clasp#versions)
|
|
50
|
+
- [`mutli-clasp run [functionName] [--nondev] [--params <StringArray>]`](https://github.com/google/clasp#run)
|
|
41
51
|
|
|
42
|
-
- `--retry <n>`: If the push of an App Script fail with it will retry <n> times. Default is 1.
|
package/build/common.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.genericAction = exports.foreachClasp = exports.readMultiClaspConfig = exports.runClasp = void 0;
|
|
13
|
+
const fs = require("fs");
|
|
14
|
+
const config_1 = require("./config");
|
|
15
|
+
const utils_1 = require("./utils");
|
|
16
|
+
/**
|
|
17
|
+
* Push a Clasp configuration
|
|
18
|
+
*
|
|
19
|
+
* @param claspConfig the single clasp config
|
|
20
|
+
* @param command the clasp command to execute
|
|
21
|
+
* @param options the command options
|
|
22
|
+
* @return true if ok, false otherwise
|
|
23
|
+
*/
|
|
24
|
+
function runClasp(claspConfig, command, options = "") {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
if (!claspConfig || !claspConfig.scriptId || !command) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
yield fs.writeFile(config_1.Config.CLASP_FILENAME, JSON.stringify(claspConfig, null, 2), config_1.Config.UTF_8, (err) => __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
if (err)
|
|
31
|
+
throw err;
|
|
32
|
+
}));
|
|
33
|
+
console.log('Elaborating scriptId:', claspConfig.scriptId);
|
|
34
|
+
try {
|
|
35
|
+
// const { stdout } = await exec(`npx clasp ${command} ${options}`);
|
|
36
|
+
const { error, stdout, stderr } = yield (0, utils_1.execShellCommand)(`npx clasp ${command} ${options}`);
|
|
37
|
+
console.log(stdout);
|
|
38
|
+
if (error) {
|
|
39
|
+
console.log(stderr);
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
console.error(e.stderr);
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
return true;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
exports.runClasp = runClasp;
|
|
51
|
+
/**
|
|
52
|
+
* Read a Multi Clasp Config.
|
|
53
|
+
*
|
|
54
|
+
* @returns array of SingleClasp
|
|
55
|
+
*/
|
|
56
|
+
function readMultiClaspConfig() {
|
|
57
|
+
return JSON.parse(fs.readFileSync(config_1.Config.MULTICLASP_FILENAME, config_1.Config.UTF_8).toString());
|
|
58
|
+
}
|
|
59
|
+
exports.readMultiClaspConfig = readMultiClaspConfig;
|
|
60
|
+
/**
|
|
61
|
+
* commander action to run clasp.
|
|
62
|
+
*
|
|
63
|
+
* @returns
|
|
64
|
+
*/
|
|
65
|
+
function foreachClasp(fn) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
const clasps = readMultiClaspConfig();
|
|
68
|
+
for (let i = 0, len = clasps.length; i < len; i++) {
|
|
69
|
+
yield fn(clasps[i]);
|
|
70
|
+
}
|
|
71
|
+
fs.unlink(config_1.Config.CLASP_FILENAME, (err) => {
|
|
72
|
+
if (err)
|
|
73
|
+
throw err;
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
exports.foreachClasp = foreachClasp;
|
|
78
|
+
/**
|
|
79
|
+
* commander action to run clasp.
|
|
80
|
+
*
|
|
81
|
+
* @returns
|
|
82
|
+
*/
|
|
83
|
+
function genericAction() {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
foreachClasp((claspConfig) => __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
const retVal = yield runClasp(claspConfig, process.argv[2], (0, utils_1.getOptions)());
|
|
87
|
+
if (!retVal) {
|
|
88
|
+
process.exit(1);
|
|
89
|
+
}
|
|
90
|
+
}));
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
exports.genericAction = genericAction;
|
|
94
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yBAAyB;AACzB,qCAAkC;AAClC,mCAAqD;AAGrD;;;;;;;GAOG;AACH,SAAsB,QAAQ,CAAC,WAAuB,EAAE,OAAe,EAAE,OAAO,GAAG,EAAE;;QACjF,IAAG,CAAC,WAAW,IAAI,CAAC,WAAW,CAAC,QAAQ,IAAI,CAAC,OAAO,EAAE;YAClD,OAAO,KAAK,CAAC;SAChB;QAED,MAAM,EAAE,CAAC,SAAS,CAAC,eAAM,CAAC,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,EAAG,eAAM,CAAC,KAAuB,EAAE,CAAO,GAAG,EAAE,EAAE;YAC3H,IAAI,GAAG;gBAAE,MAAM,GAAG,CAAC;QACvB,CAAC,CAAA,CAAC,CAAC;QACH,OAAO,CAAC,GAAG,CAAC,uBAAuB,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;QAE3D,IAAI;YACA,oEAAoE;YACpE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAA,w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E,CAAC,CAAC;YAC1E,IAAG,CAAC,MAAM,EAAC;gBACT,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;aACjB;QACH,CAAC,CAAA,CAAC,CAAC;IACL,CAAC;CAAA;AAPD,sCAOC"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;AAAa,QAAA,MAAM,GAAG;IAClB,cAAc,EAAE,aAAa;IAC7B,mBAAmB,EAAE,mBAAmB;IACxC,KAAK,EAAE,MAAM;CAChB,CAAC"}
|
package/build/index.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#! /usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const common_1 = require("./common");
|
|
6
|
+
const run_1 = require("./run");
|
|
7
|
+
const push_1 = require("./push");
|
|
8
|
+
const program = new commander_1.Command();
|
|
9
|
+
program
|
|
10
|
+
.command('status')
|
|
11
|
+
.description('Lists files that will be pushed by clasp')
|
|
12
|
+
.option('--json', 'Show status in JSON form')
|
|
13
|
+
.action(common_1.genericAction);
|
|
14
|
+
program
|
|
15
|
+
.command('push')
|
|
16
|
+
.description('Update the remote project')
|
|
17
|
+
.option('-f, --force', 'Forcibly overwrites the remote manifest.')
|
|
18
|
+
.option('--retry <n>', 'If the push of an App Script fail with it will retry n times. Default is 1.', '1')
|
|
19
|
+
.action(push_1.default);
|
|
20
|
+
program
|
|
21
|
+
.command('open')
|
|
22
|
+
.description('Open a script')
|
|
23
|
+
.option('--webapp', 'Open web application in the browser')
|
|
24
|
+
.option('--creds', 'Open the URL to create credentials')
|
|
25
|
+
.option('--addon', 'List parent IDs and open the URL of the first one')
|
|
26
|
+
.action(common_1.genericAction);
|
|
27
|
+
program.command('deployments')
|
|
28
|
+
.description('List deployment ids of a script')
|
|
29
|
+
.action(common_1.genericAction);
|
|
30
|
+
program
|
|
31
|
+
.command('deploy')
|
|
32
|
+
.description('Deploy a project')
|
|
33
|
+
.option('-V, --versionNumber <version>', 'The project version') // We can't use `version` in subcommand
|
|
34
|
+
.option('-d, --description <description>', 'The deployment description')
|
|
35
|
+
.action(common_1.genericAction);
|
|
36
|
+
program
|
|
37
|
+
.command('undeploy')
|
|
38
|
+
.description('Undeploy a deployment of a project')
|
|
39
|
+
.option('-a, --all', 'Undeploy all deployments')
|
|
40
|
+
.action(common_1.genericAction);
|
|
41
|
+
program
|
|
42
|
+
.command('run [functionName]')
|
|
43
|
+
.description('Run a function in your Apps Scripts project')
|
|
44
|
+
.option('--nondev', 'Run script function in non-devMode')
|
|
45
|
+
.option('-p, --params [StringArray]', 'Add parameters required for the function as a JSON String Array')
|
|
46
|
+
.action(run_1.default);
|
|
47
|
+
program
|
|
48
|
+
.command('version [description]')
|
|
49
|
+
.description('Creates an immutable version of the script')
|
|
50
|
+
.action(common_1.genericAction);
|
|
51
|
+
program
|
|
52
|
+
.command('versions')
|
|
53
|
+
.description('List versions of a script')
|
|
54
|
+
.action(common_1.genericAction);
|
|
55
|
+
program.version(process.env.npm_package_version || 'unknown', '-v, --version', 'output the current version');
|
|
56
|
+
program.parse();
|
|
57
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAEA,yCAAoC;AACpC,qCAAyC;AACzC,+BAAwB;AACxB,iCAA0B;AAE1B,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,OAAO,CAAC,QAAQ,CAAC;KACjB,WAAW,CAAC,0CAA0C,CAAC;KACvD,MAAM,CAAC,QAAQ,EAAE,0BAA0B,CAAC;KAC5C,MAAM,CAAC,sBAAa,CAAC,CAAC;AAEzB,OAAO;KACJ,OAAO,CAAC,MAAM,CAAC;KACf,W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B,OAAO;KACJ,OAAO,CAAC,UAAU,CAAC;KACnB,WAAW,CAAC,2BAA2B,CAAC;KACxC,MAAM,CAAC,sBAAa,CAAC,CAAC;AAEzB,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,SAAS,EAAE,eAAe,EAAE,4BAA4B,CAAC,CAAC;AAC7G,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MultiClaspErrors = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Multi Clasp Errors.
|
|
6
|
+
*/
|
|
7
|
+
var MultiClaspErrors;
|
|
8
|
+
(function (MultiClaspErrors) {
|
|
9
|
+
MultiClaspErrors["InvalidJson"] = "Invalid json";
|
|
10
|
+
MultiClaspErrors["ClaspError"] = "Clasp Error";
|
|
11
|
+
})(MultiClaspErrors = exports.MultiClaspErrors || (exports.MultiClaspErrors = {}));
|
|
12
|
+
//# sourceMappingURL=mutli-clasp-errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutli-clasp-errors.js","sourceRoot":"","sources":["../src/mutli-clasp-errors.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,gDAA4B,CAAA;IAC5B,8CAA0B,CAAA;AAC5B,CAAC,EAHW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAG3B"}
|
package/build/push.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const common_1 = require("./common");
|
|
13
|
+
/**
|
|
14
|
+
* Get Clasp Arguments.
|
|
15
|
+
*
|
|
16
|
+
* @param options.nondev {boolean} If we want to push the last deployed version vs the latest code.
|
|
17
|
+
* @param options.retry {number} If the push of an App Script fail with it will retry n times
|
|
18
|
+
* @returns {string} the command arguments
|
|
19
|
+
*/
|
|
20
|
+
function getPushClaspArgs(options) {
|
|
21
|
+
let claspArgs = "";
|
|
22
|
+
if (!options) {
|
|
23
|
+
return claspArgs;
|
|
24
|
+
}
|
|
25
|
+
claspArgs += options.force ? " --force" : "";
|
|
26
|
+
return claspArgs;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Uploads all files into the script.google.com filesystem.
|
|
30
|
+
* @param options.watch {boolean} If true, runs `clasp push` when any local file changes. Exit with ^C.
|
|
31
|
+
* @param options.retry {number} If the push of an App Script fail with it will retry n times
|
|
32
|
+
*/
|
|
33
|
+
exports.default = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
+
const retry = parseInt(options.retry);
|
|
35
|
+
(0, common_1.foreachClasp)((claspConfig) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
+
let retVal = false;
|
|
37
|
+
for (let r = 0; r < retry; r++) {
|
|
38
|
+
retVal = yield (0, common_1.runClasp)(claspConfig, process.argv[2], getPushClaspArgs(options));
|
|
39
|
+
if (retVal) {
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (!retVal) {
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
}));
|
|
47
|
+
});
|
|
48
|
+
//# sourceMappingURL=push.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"push.js","sourceRoot":"","sources":["../src/push.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,qCAAgD;AAOhD;;;;;;GAMG;AACH,SAAS,gBAAgB,CAAC,OAAsB;IAC9C,IAAI,SAAS,GAAG,EAAE,CAAC;IAEnB,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,SAAS,CAAC;KAClB;IAED,SAAS,IAAI,OAAO,CAAC,KAAK,CAAA,CAAC,CAAA,UAAU,CAAA,CAAC,CAAA,EAAE,CAAC;IAEzC,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;GAIG;AACH,kBAAe,CAAO,OAAsB,EAAiB,EAAE;IAC7D,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAEtC,IAAA,qBAAY,EAAC,CAAO,WAAW,EAAC,EAAE;QAChC,IAAI,MAAM,GAAG,KAAK,CAAC;QAEnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE;YAC9B,MAAM,GAAG,MAAM,IAAA,iBAAQ,EAAC,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;YACjF,IAAG,MAAM,EAAC;gBACR,MAAM;aACP;SACF;QACD,IAAG,CAAC,MAAM,EAAC;YACT,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACjB;IACH,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAA,CAAC"}
|
package/build/run.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getRunClaspArgs = void 0;
|
|
13
|
+
const common_1 = require("./common");
|
|
14
|
+
const utils_1 = require("./utils");
|
|
15
|
+
/**
|
|
16
|
+
* Get Clasp Arguments.
|
|
17
|
+
*
|
|
18
|
+
* @param functionName {string} The function name within the Apps Script project.
|
|
19
|
+
* @param options.nondev {boolean} If we want to run the last deployed version vs the latest code.
|
|
20
|
+
* @param options.params {string} JSON string of parameters to be input to function.
|
|
21
|
+
* @returns {string} the command arguments
|
|
22
|
+
*/
|
|
23
|
+
function getRunClaspArgs(functionName = "", options) {
|
|
24
|
+
let claspArgs = functionName || "";
|
|
25
|
+
const { params: jsonString = '[]' } = options;
|
|
26
|
+
const parameters = (0, utils_1.parseJsonOrDie)(jsonString);
|
|
27
|
+
if (!options) {
|
|
28
|
+
return claspArgs;
|
|
29
|
+
}
|
|
30
|
+
claspArgs += options.nondev ? " --nondev" : "";
|
|
31
|
+
claspArgs += " --params '" + JSON.stringify(parameters) + "'";
|
|
32
|
+
return claspArgs;
|
|
33
|
+
}
|
|
34
|
+
exports.getRunClaspArgs = getRunClaspArgs;
|
|
35
|
+
/**
|
|
36
|
+
* Executes an Apps Script function. Requires clasp login --creds.
|
|
37
|
+
* @param functionName {string} The function name within the Apps Script project.
|
|
38
|
+
* @param options.nondev {boolean} If we want to run the last deployed version vs the latest code.
|
|
39
|
+
* @param options.params {string} JSON string of parameters to be input to function.
|
|
40
|
+
* @see https://developers.google.com/apps-script/api/how-tos/execute
|
|
41
|
+
* @requires `clasp login --creds` to be run beforehand.
|
|
42
|
+
*/
|
|
43
|
+
exports.default = (functionName, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
44
|
+
const claspArgs = getRunClaspArgs(functionName, options);
|
|
45
|
+
(0, common_1.foreachClasp)((claspConfig) => __awaiter(void 0, void 0, void 0, function* () {
|
|
46
|
+
yield (0, common_1.runClasp)(claspConfig, process.argv[2], claspArgs);
|
|
47
|
+
}));
|
|
48
|
+
});
|
|
49
|
+
//# sourceMappingURL=run.js.map
|
package/build/run.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAgD;AAChD,mCAAuC;AAOvC;;;;;;;GAOG;AACH,SAAgB,eAAe,CAAC,YAAY,GAAC,EAAE,EAAE,OAAsB;IACrE,IAAI,SAAS,GAAG,YAAY,IAAI,EAAE,CAAC;IACnC,MAAM,EAAC,MAAM,EAAE,UAAU,GAAG,IAAI,EAAC,GAAG,OAAO,CAAC;IAC5C,MAAM,UAAU,GAAG,IAAA,sBAAc,EAAW,UAAU,CAAC,CAAC;IAExD,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,SAAS,CAAC;KAClB;IAED,SAAS,IAAI,OAAO,CAAC,MAAM,CAAA,CAAC,CAAA,WAAW,CAAA,CAAC,CAAA,EAAE,CAAC;IAE3C,SAAS,IAAI,aAAa,GAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,GAAC,GAAG,CAAC;IAE1D,OAAO,SAAS,CAAC;AACnB,CAAC;AAdD,0CAcC;AAED;;;;;;;GAOG;AACH,kBAAe,CAAO,YAAoB,EAAE,OAAsB,EAAiB,EAAE;IACnF,MAAM,SAAS,GAAG,eAAe,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IAEzD,IAAA,qBAAY,EAAC,CAAO,WAAW,EAAC,EAAE;QAChC,MAAM,IAAA,iBAAQ,EAAC,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;IAC1D,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAA,CAAA"}
|
package/build/utils.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.execShellCommand = exports.getOptions = exports.parseJsonOrDie = void 0;
|
|
4
|
+
const mutli_clasp_errors_1 = require("./mutli-clasp-errors");
|
|
5
|
+
const child_process = require("child_process");
|
|
6
|
+
/**
|
|
7
|
+
* Parses input string into a valid JSON object or throws a `ClaspError` error.
|
|
8
|
+
* @param value JSON string.
|
|
9
|
+
*/
|
|
10
|
+
const parseJsonOrDie = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
return JSON.parse(value);
|
|
13
|
+
}
|
|
14
|
+
catch (_a) {
|
|
15
|
+
throw mutli_clasp_errors_1.MultiClaspErrors.InvalidJson;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
exports.parseJsonOrDie = parseJsonOrDie;
|
|
19
|
+
/**
|
|
20
|
+
* Get the Options for the clasp command.
|
|
21
|
+
*
|
|
22
|
+
* @param args array of arguments
|
|
23
|
+
* @returns the string with the options, "" otherwise
|
|
24
|
+
*/
|
|
25
|
+
function getOptions(args = process.argv) {
|
|
26
|
+
if (!args) {
|
|
27
|
+
return "";
|
|
28
|
+
}
|
|
29
|
+
return args.slice(3).join(' ');
|
|
30
|
+
}
|
|
31
|
+
exports.getOptions = getOptions;
|
|
32
|
+
/**
|
|
33
|
+
* Executes a shell command and return it as a Promise.
|
|
34
|
+
* @param cmd the shell command to execute.
|
|
35
|
+
* @return the promise
|
|
36
|
+
*/
|
|
37
|
+
function execShellCommand(cmd) {
|
|
38
|
+
return new Promise((resolve) => {
|
|
39
|
+
child_process.exec(cmd, (error, stdout, stderr) => {
|
|
40
|
+
resolve({ error, stdout, stderr });
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
exports.execShellCommand = execShellCommand;
|
|
45
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAAA,6DAAsD;AACtD,+CAA+C;AAE/C;;;GAGG;AACI,MAAM,cAAc,GAAG,CAAI,KAAa,EAAK,EAAE;IACpD,IAAI;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAM,CAAC;KAC/B;IAAC,WAAM;QACN,MAAM,qCAAgB,CAAC,WAAW,CAAC;KACpC;AACH,CAAC,CAAC;AANW,QAAA,cAAc,kBAMzB;AAEF;;;;;GAKG;AACH,SAAgB,UAAU,CAAE,OAAc,OAAO,CAAC,IAAI;IACpD,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,EAAE,CAAC;KACX;IACD,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACjC,CAAC;AALD,gCAKC;AAED;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,GAAW;IAC1C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,aAAa,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;YAChD,OAAO,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAND,4CAMC"}
|
package/package.json
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "multi-clasp2",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"description": "Google Clasp wrapper to push changes to multiple Apps Script projects at once.",
|
|
5
|
-
"exports": "./build/
|
|
6
|
-
"main": "build/
|
|
5
|
+
"exports": "./build/index.js",
|
|
6
|
+
"main": "build/index.js",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@google/clasp": "2.4.1",
|
|
9
|
-
"
|
|
9
|
+
"commander": "^8.3.0",
|
|
10
10
|
"typescript": "^4.4.4"
|
|
11
11
|
},
|
|
12
12
|
"author": "Fabrizio Antonangeli",
|
|
13
13
|
"license": "GPL-3.0",
|
|
14
14
|
"scripts": {
|
|
15
|
-
"test": "jest",
|
|
15
|
+
"test": "jest --silent",
|
|
16
16
|
"lint": "eslint .",
|
|
17
17
|
"release": "release-it",
|
|
18
|
-
"build": "tsc"
|
|
18
|
+
"build": "tsc",
|
|
19
|
+
"build-watch": "tsc --watch",
|
|
20
|
+
"start": "node build/index.js"
|
|
19
21
|
},
|
|
20
22
|
"repository": {
|
|
21
23
|
"type": "git",
|
|
@@ -33,10 +35,10 @@
|
|
|
33
35
|
},
|
|
34
36
|
"homepage": "https://github.com/fantonangeli/multi-clasp2",
|
|
35
37
|
"bin": {
|
|
36
|
-
"multi-clasp": "build/
|
|
38
|
+
"multi-clasp": "build/index.js"
|
|
37
39
|
},
|
|
38
40
|
"files": [
|
|
39
|
-
"build
|
|
41
|
+
"build"
|
|
40
42
|
],
|
|
41
43
|
"devDependencies": {
|
|
42
44
|
"@types/jest": "^27.0.2",
|
package/build/src/common.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.pushClasp = void 0;
|
|
13
|
-
const fs = require("fs");
|
|
14
|
-
const util = require("util");
|
|
15
|
-
const child_process = require("child_process");
|
|
16
|
-
const exec = util.promisify(child_process.exec);
|
|
17
|
-
const config_1 = require("./config");
|
|
18
|
-
/**
|
|
19
|
-
* Push a Clasp configuration
|
|
20
|
-
*
|
|
21
|
-
* @param {SingleClasp} clasp the single clasp config
|
|
22
|
-
* @return true if ok, false otherwise
|
|
23
|
-
*/
|
|
24
|
-
function pushClasp(clasp) {
|
|
25
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
if (!clasp || !clasp.scriptId) {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
yield fs.writeFile(config_1.Config.CLASP_FILENAME, JSON.stringify(clasp, null, 2), config_1.Config.UTF_8, (err) => __awaiter(this, void 0, void 0, function* () {
|
|
30
|
-
if (err)
|
|
31
|
-
throw err;
|
|
32
|
-
}));
|
|
33
|
-
console.log('Pushing scriptId:', clasp.scriptId);
|
|
34
|
-
try {
|
|
35
|
-
const { stdout } = yield exec('clasp push');
|
|
36
|
-
console.log('stdout:', stdout);
|
|
37
|
-
}
|
|
38
|
-
catch (e) {
|
|
39
|
-
console.error(e); // should contain code (exit code) and signal (that caused the termination).
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
return true;
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
exports.pushClasp = pushClasp;
|
|
46
|
-
//# sourceMappingURL=common.js.map
|
package/build/src/common.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/common.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yBAAyB;AACzB,6BAA6B;AAC7B,+CAA+C;AAC/C,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;AAChD,qCAAkC;AAGlC;;;;;GAKG;AACH,SAAsB,SAAS,CAAC,KAAiB;;QAC7C,IAAG,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;YAC1B,OAAO,KAAK,CAAC;SAChB;QAED,MAAM,EAAE,CAAC,SAAS,CAAC,eAAM,CAAC,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,EAAG,eAAM,CAAC,KAAuB,EAAE,CAAO,GAAG,EAAE,EAAE;YACrH,IAAI,GAAG;gBAAE,MAAM,GAAG,CAAC;QACvB,CAAC,CAAA,CAAC,CAAC;QACH,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;QAEjD,IAAI;YACA,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,CAAC;YAC5C,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;SAClC;QAAC,OAAO,CAAC,EAAE;YACR,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,4EAA4E;YAC9F,OAAO,KAAK,CAAC;SAChB;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;CAAA;AAnBD,8BAmBC"}
|
package/build/src/config.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":";;;AAAa,QAAA,MAAM,GAAG;IAClB,cAAc,EAAE,aAAa;IAC7B,mBAAmB,EAAE,mBAAmB;IACxC,KAAK,EAAE,MAAM;CAChB,CAAC"}
|
package/build/src/index.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
#! /usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
-
});
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
const fs = require("fs");
|
|
14
|
-
const minimist = require("minimist");
|
|
15
|
-
const rootCommand = process.argv[2];
|
|
16
|
-
const argv = minimist(process.argv.slice(2));
|
|
17
|
-
const config_1 = require("./config");
|
|
18
|
-
const common_1 = require("./common");
|
|
19
|
-
const clasps = JSON.parse(fs.readFileSync(config_1.Config.MULTICLASP_FILENAME, config_1.Config.UTF_8).toString());
|
|
20
|
-
({
|
|
21
|
-
push() {
|
|
22
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
for (let i = 0, len = clasps.length; i < len; i++) {
|
|
24
|
-
let retVal = false;
|
|
25
|
-
for (let r = 1; r <= (argv.retry || 1); r++) {
|
|
26
|
-
retVal = yield (0, common_1.pushClasp)(clasps[i]);
|
|
27
|
-
if (retVal)
|
|
28
|
-
break;
|
|
29
|
-
}
|
|
30
|
-
if (!retVal)
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
fs.unlink(config_1.Config.CLASP_FILENAME, (err) => {
|
|
34
|
-
if (err)
|
|
35
|
-
throw err;
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
},
|
|
39
|
-
})[rootCommand]();
|
|
40
|
-
//# sourceMappingURL=index.js.map
|
package/build/src/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,yBAAyB;AACzB,qCAAqC;AAErC,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAEpC,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7C,qCAAkC;AAElC,qCAAqC;AAErC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,eAAM,CAAC,mBAAmB,EAAE,eAAM,CAAC,KAAuB,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;AAClH,CAAC;IACO,IAAI;;YACN,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;gBAC/C,IAAI,MAAM,GAAC,KAAK,CAAC;gBACjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;oBACzC,MAAM,GAAC,MAAM,IAAA,kBAAS,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;oBAClC,IAAI,MAAM;wBAAE,MAAM;iBACrB;gBACD,IAAG,CAAC,MAAM;oBAAE,OAAO,KAAK,CAAC;aAC5B;YAED,EAAE,CAAC,MAAM,CAAC,eAAM,CAAC,cAAc,EAAE,CAAC,GAAG,EAAE,EAAE;gBACrC,IAAI,GAAG;oBAAE,MAAM,GAAG,CAAC;YACvB,CAAC,CAAC,CAAC;QACP,CAAC;KAAA;CACF,CAAC,CAAC,WAAW,CAAC,EAAE,CAAC"}
|