firebase-tools 11.10.0 → 11.10.1-canary.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/lib/bin/firebase.js +15 -4
- package/lib/deploy/functions/release/fabricator.js +3 -35
- package/lib/emulator/storage/apis/firebase.js +1 -1
- package/lib/functions/projectConfig.js +14 -6
- package/lib/gcp/run.js +40 -2
- package/lib/init/features/functions/index.js +122 -13
- package/lib/init/features/functions/javascript.js +8 -7
- package/lib/init/features/functions/npm-dependencies.js +1 -1
- package/lib/init/features/functions/typescript.js +15 -13
- package/npm-shrinkwrap.json +5419 -18301
- package/package.json +1 -109
- package/lib/extensions/changelog.js +0 -95
- package/templates/extensions/CHANGELOG.md +0 -1
package/lib/bin/firebase.js
CHANGED
|
@@ -102,10 +102,21 @@ process.on("exit", (code) => {
|
|
|
102
102
|
else {
|
|
103
103
|
configstore_1.configstore.delete("lastError");
|
|
104
104
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
105
|
+
try {
|
|
106
|
+
const updateMessage = `Update available ${clc.gray("{currentVersion}")} → ${clc.green("{latestVersion}")}\n` +
|
|
107
|
+
`To update to the latest version using npm, run\n${clc.cyan("npm install -g firebase-tools")}\n` +
|
|
108
|
+
`For other CLI management options, visit the ${(0, marked_1.marked)("[CLI documentation](https://firebase.google.com/docs/cli#update-cli)")}`;
|
|
109
|
+
updateNotifier.notify({ defer: false, isGlobal: true, message: updateMessage });
|
|
110
|
+
}
|
|
111
|
+
catch (err) {
|
|
112
|
+
logger_1.logger.debug("Error when notifying about new CLI updates:");
|
|
113
|
+
if (err instanceof Error) {
|
|
114
|
+
logger_1.logger.debug(err);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
logger_1.logger.debug(`${err}`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
109
120
|
});
|
|
110
121
|
process.on("uncaughtException", (err) => {
|
|
111
122
|
(0, errorOut_1.errorOut)(err);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.Fabricator = void 0;
|
|
4
4
|
const clc = require("colorette");
|
|
5
5
|
const error_1 = require("../../../error");
|
|
6
6
|
const sourceTokenScraper_1 = require("./sourceTokenScraper");
|
|
@@ -23,7 +23,6 @@ const scheduler = require("../../../gcp/cloudscheduler");
|
|
|
23
23
|
const utils = require("../../../utils");
|
|
24
24
|
const services = require("../services");
|
|
25
25
|
const v1_1 = require("../../../functions/events/v1");
|
|
26
|
-
const throttler_1 = require("../../../throttler/throttler");
|
|
27
26
|
const checkIam_1 = require("../checkIam");
|
|
28
27
|
const gcfV1PollerOptions = {
|
|
29
28
|
apiOrigin: api_1.functionsOrigin,
|
|
@@ -401,7 +400,7 @@ class Fabricator {
|
|
|
401
400
|
async setRunTraits(serviceName, endpoint) {
|
|
402
401
|
await this.functionExecutor
|
|
403
402
|
.run(async () => {
|
|
404
|
-
|
|
403
|
+
const service = await run.getService(serviceName);
|
|
405
404
|
let changed = false;
|
|
406
405
|
if (service.spec.template.spec.containerConcurrency !== endpoint.concurrency) {
|
|
407
406
|
service.spec.template.spec.containerConcurrency = endpoint.concurrency;
|
|
@@ -415,15 +414,7 @@ class Fabricator {
|
|
|
415
414
|
logger_1.logger.debug("Skipping setRunTraits on", serviceName, " because it already matches");
|
|
416
415
|
return;
|
|
417
416
|
}
|
|
418
|
-
|
|
419
|
-
delete service.spec.template.metadata.name;
|
|
420
|
-
service = await run.replaceService(serviceName, service);
|
|
421
|
-
let retry = 0;
|
|
422
|
-
while (!exports.serviceIsResolved(service)) {
|
|
423
|
-
await (0, throttler_1.backoff)(retry, 2, 30);
|
|
424
|
-
retry = retry + 1;
|
|
425
|
-
service = await run.getService(serviceName);
|
|
426
|
-
}
|
|
417
|
+
await run.updateService(serviceName, service);
|
|
427
418
|
})
|
|
428
419
|
.catch(rethrowAs(endpoint, "set concurrency"));
|
|
429
420
|
}
|
|
@@ -547,26 +538,3 @@ class Fabricator {
|
|
|
547
538
|
}
|
|
548
539
|
}
|
|
549
540
|
exports.Fabricator = Fabricator;
|
|
550
|
-
function serviceIsResolved(service) {
|
|
551
|
-
var _a, _b, _c, _d, _e;
|
|
552
|
-
if (((_a = service.status) === null || _a === void 0 ? void 0 : _a.observedGeneration) !== service.metadata.generation) {
|
|
553
|
-
logger_1.logger.debug(`Service ${service.metadata.name} is not resolved because` +
|
|
554
|
-
`observed generation ${(_b = service.status) === null || _b === void 0 ? void 0 : _b.observedGeneration} does not ` +
|
|
555
|
-
`match spec generation ${service.metadata.generation}`);
|
|
556
|
-
return false;
|
|
557
|
-
}
|
|
558
|
-
const readyCondition = (_d = (_c = service.status) === null || _c === void 0 ? void 0 : _c.conditions) === null || _d === void 0 ? void 0 : _d.find((condition) => {
|
|
559
|
-
return condition.type === "Ready";
|
|
560
|
-
});
|
|
561
|
-
if ((readyCondition === null || readyCondition === void 0 ? void 0 : readyCondition.status) === "Unknown") {
|
|
562
|
-
logger_1.logger.debug(`Waiting for service ${service.metadata.name} to be ready. ` +
|
|
563
|
-
`Status is ${JSON.stringify((_e = service.status) === null || _e === void 0 ? void 0 : _e.conditions)}`);
|
|
564
|
-
return false;
|
|
565
|
-
}
|
|
566
|
-
else if ((readyCondition === null || readyCondition === void 0 ? void 0 : readyCondition.status) === "True") {
|
|
567
|
-
return true;
|
|
568
|
-
}
|
|
569
|
-
logger_1.logger.debug(`Service ${service.metadata.name} has unexpected ready status ${JSON.stringify(readyCondition)}. It may have failed rollout.`);
|
|
570
|
-
throw new error_1.FirebaseError(`Unexpected Status ${readyCondition === null || readyCondition === void 0 ? void 0 : readyCondition.status} for service ${service.metadata.name}`);
|
|
571
|
-
}
|
|
572
|
-
exports.serviceIsResolved = serviceIsResolved;
|
|
@@ -201,7 +201,7 @@ function createFirebaseEndpoints(emulator) {
|
|
|
201
201
|
}
|
|
202
202
|
return res.status(200).json(new metadata_1.OutgoingFirebaseMetadata(metadata));
|
|
203
203
|
}
|
|
204
|
-
if (uploadType === "resumable") {
|
|
204
|
+
if (uploadType === "resumable" || req.header("x-goog-upload-command")) {
|
|
205
205
|
const uploadCommand = req.header("x-goog-upload-command");
|
|
206
206
|
if (!uploadCommand) {
|
|
207
207
|
res.sendStatus(400);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.configForCodebase = exports.normalizeAndValidate = exports.validate = exports.normalize = exports.DEFAULT_CODEBASE = void 0;
|
|
3
|
+
exports.configForCodebase = exports.normalizeAndValidate = exports.validate = exports.assertUnique = exports.validateCodebase = exports.normalize = exports.DEFAULT_CODEBASE = void 0;
|
|
4
4
|
const error_1 = require("../error");
|
|
5
5
|
exports.DEFAULT_CODEBASE = "default";
|
|
6
6
|
function normalize(config) {
|
|
@@ -16,6 +16,13 @@ function normalize(config) {
|
|
|
16
16
|
return [config];
|
|
17
17
|
}
|
|
18
18
|
exports.normalize = normalize;
|
|
19
|
+
function validateCodebase(codebase) {
|
|
20
|
+
if (codebase.length === 0 || codebase.length > 63 || !/^[a-z0-9_-]+$/.test(codebase)) {
|
|
21
|
+
throw new error_1.FirebaseError("Invalid codebase name. Codebase must be less than 64 characters and " +
|
|
22
|
+
"can contain only lowercase letters, numeric characters, underscores, and dashes.");
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.validateCodebase = validateCodebase;
|
|
19
26
|
function validateSingle(config) {
|
|
20
27
|
if (!config.source) {
|
|
21
28
|
throw new error_1.FirebaseError("functions.source must be specified");
|
|
@@ -23,14 +30,14 @@ function validateSingle(config) {
|
|
|
23
30
|
if (!config.codebase) {
|
|
24
31
|
config.codebase = exports.DEFAULT_CODEBASE;
|
|
25
32
|
}
|
|
26
|
-
|
|
27
|
-
throw new error_1.FirebaseError("Invalid codebase name. Codebase must be less than 63 characters and " +
|
|
28
|
-
"can contain only lowercase letters, numeric characters, underscores, and dashes.");
|
|
29
|
-
}
|
|
33
|
+
validateCodebase(config.codebase);
|
|
30
34
|
return Object.assign(Object.assign({}, config), { source: config.source, codebase: config.codebase });
|
|
31
35
|
}
|
|
32
|
-
function assertUnique(config, property) {
|
|
36
|
+
function assertUnique(config, property, propval) {
|
|
33
37
|
const values = new Set();
|
|
38
|
+
if (propval) {
|
|
39
|
+
values.add(propval);
|
|
40
|
+
}
|
|
34
41
|
for (const single of config) {
|
|
35
42
|
const value = single[property];
|
|
36
43
|
if (values.has(value)) {
|
|
@@ -39,6 +46,7 @@ function assertUnique(config, property) {
|
|
|
39
46
|
values.add(value);
|
|
40
47
|
}
|
|
41
48
|
}
|
|
49
|
+
exports.assertUnique = assertUnique;
|
|
42
50
|
function validate(config) {
|
|
43
51
|
const validated = config.map((cfg) => validateSingle(cfg));
|
|
44
52
|
assertUnique(validated, "source");
|
package/lib/gcp/run.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setInvokerUpdate = exports.setInvokerCreate = exports.getIamPolicy = exports.setIamPolicy = exports.replaceService = exports.getService = exports.LOCATION_LABEL = void 0;
|
|
3
|
+
exports.setInvokerUpdate = exports.setInvokerCreate = exports.getIamPolicy = exports.setIamPolicy = exports.replaceService = exports.serviceIsResolved = exports.updateService = exports.getService = exports.LOCATION_LABEL = void 0;
|
|
4
4
|
const apiv2_1 = require("../apiv2");
|
|
5
5
|
const error_1 = require("../error");
|
|
6
6
|
const api_1 = require("../api");
|
|
7
7
|
const proto = require("./proto");
|
|
8
|
+
const throttler_1 = require("../throttler/throttler");
|
|
9
|
+
const logger_1 = require("../logger");
|
|
8
10
|
const API_VERSION = "v1";
|
|
9
11
|
const client = new apiv2_1.Client({
|
|
10
12
|
urlPrefix: api_1.runOrigin,
|
|
@@ -24,13 +26,49 @@ async function getService(name) {
|
|
|
24
26
|
}
|
|
25
27
|
}
|
|
26
28
|
exports.getService = getService;
|
|
29
|
+
async function updateService(name, service) {
|
|
30
|
+
delete service.status;
|
|
31
|
+
delete service.spec.template.metadata.name;
|
|
32
|
+
service = await exports.replaceService(name, service);
|
|
33
|
+
let retry = 0;
|
|
34
|
+
while (!exports.serviceIsResolved(service)) {
|
|
35
|
+
await (0, throttler_1.backoff)(retry, 2, 30);
|
|
36
|
+
retry = retry + 1;
|
|
37
|
+
service = await exports.getService(name);
|
|
38
|
+
}
|
|
39
|
+
return service;
|
|
40
|
+
}
|
|
41
|
+
exports.updateService = updateService;
|
|
42
|
+
function serviceIsResolved(service) {
|
|
43
|
+
var _a, _b, _c, _d, _e;
|
|
44
|
+
if (((_a = service.status) === null || _a === void 0 ? void 0 : _a.observedGeneration) !== service.metadata.generation) {
|
|
45
|
+
logger_1.logger.debug(`Service ${service.metadata.name} is not resolved because` +
|
|
46
|
+
`observed generation ${(_b = service.status) === null || _b === void 0 ? void 0 : _b.observedGeneration} does not ` +
|
|
47
|
+
`match spec generation ${service.metadata.generation}`);
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
const readyCondition = (_d = (_c = service.status) === null || _c === void 0 ? void 0 : _c.conditions) === null || _d === void 0 ? void 0 : _d.find((condition) => {
|
|
51
|
+
return condition.type === "Ready";
|
|
52
|
+
});
|
|
53
|
+
if ((readyCondition === null || readyCondition === void 0 ? void 0 : readyCondition.status) === "Unknown") {
|
|
54
|
+
logger_1.logger.debug(`Waiting for service ${service.metadata.name} to be ready. ` +
|
|
55
|
+
`Status is ${JSON.stringify((_e = service.status) === null || _e === void 0 ? void 0 : _e.conditions)}`);
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
else if ((readyCondition === null || readyCondition === void 0 ? void 0 : readyCondition.status) === "True") {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
logger_1.logger.debug(`Service ${service.metadata.name} has unexpected ready status ${JSON.stringify(readyCondition)}. It may have failed rollout.`);
|
|
62
|
+
throw new error_1.FirebaseError(`Unexpected Status ${readyCondition === null || readyCondition === void 0 ? void 0 : readyCondition.status} for service ${service.metadata.name}`);
|
|
63
|
+
}
|
|
64
|
+
exports.serviceIsResolved = serviceIsResolved;
|
|
27
65
|
async function replaceService(name, service) {
|
|
28
66
|
try {
|
|
29
67
|
const response = await client.put(name, service);
|
|
30
68
|
return response.body;
|
|
31
69
|
}
|
|
32
70
|
catch (err) {
|
|
33
|
-
throw new error_1.FirebaseError(`Failed to
|
|
71
|
+
throw new error_1.FirebaseError(`Failed to replace Run service ${name}`, {
|
|
34
72
|
original: err,
|
|
35
73
|
});
|
|
36
74
|
}
|
|
@@ -2,19 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.doSetup = void 0;
|
|
4
4
|
const clc = require("colorette");
|
|
5
|
-
const _ = require("lodash");
|
|
6
5
|
const logger_1 = require("../../../logger");
|
|
7
6
|
const prompt_1 = require("../../../prompt");
|
|
8
7
|
const requirePermissions_1 = require("../../../requirePermissions");
|
|
9
8
|
const previews_1 = require("../../../previews");
|
|
10
9
|
const ensureApiEnabled_1 = require("../../../ensureApiEnabled");
|
|
10
|
+
const projectConfig_1 = require("../../../functions/projectConfig");
|
|
11
|
+
const error_1 = require("../../../error");
|
|
12
|
+
const MAX_ATTEMPTS = 5;
|
|
11
13
|
async function doSetup(setup, config, options) {
|
|
12
14
|
var _a, _b;
|
|
13
|
-
logger_1.logger.info();
|
|
14
|
-
logger_1.logger.info("A " + clc.bold("functions") + " directory will be created in your project with sample code");
|
|
15
|
-
logger_1.logger.info("pre-configured. Functions can be deployed with " + clc.bold("firebase deploy") + ".");
|
|
16
|
-
logger_1.logger.info();
|
|
17
|
-
setup.functions = {};
|
|
18
15
|
const projectId = (_b = (_a = setup === null || setup === void 0 ? void 0 : setup.rcfile) === null || _a === void 0 ? void 0 : _a.projects) === null || _b === void 0 ? void 0 : _b.default;
|
|
19
16
|
if (projectId) {
|
|
20
17
|
await (0, requirePermissions_1.requirePermissions)(Object.assign(Object.assign({}, options), { project: projectId }));
|
|
@@ -23,6 +20,116 @@ async function doSetup(setup, config, options) {
|
|
|
23
20
|
(0, ensureApiEnabled_1.ensure)(projectId, "runtimeconfig.googleapis.com", "unused", true),
|
|
24
21
|
]);
|
|
25
22
|
}
|
|
23
|
+
setup.functions = {};
|
|
24
|
+
if (!config.src.functions) {
|
|
25
|
+
setup.config.functions = [];
|
|
26
|
+
return initNewCodebase(setup, config);
|
|
27
|
+
}
|
|
28
|
+
const codebases = setup.config.functions.map((cfg) => clc.bold(cfg.codebase));
|
|
29
|
+
logger_1.logger.info(`\nDetected existing codebase(s): ${codebases.join(", ")}\n`);
|
|
30
|
+
setup.config.functions = (0, projectConfig_1.normalizeAndValidate)(setup.config.functions);
|
|
31
|
+
const choices = [
|
|
32
|
+
{
|
|
33
|
+
name: "Initialize",
|
|
34
|
+
value: "new",
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: "Overwrite",
|
|
38
|
+
value: "overwrite",
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
const initOpt = await (0, prompt_1.promptOnce)({
|
|
42
|
+
type: "list",
|
|
43
|
+
message: "Would you like to initialize a new codebase, or overwrite an existing one?",
|
|
44
|
+
default: "new",
|
|
45
|
+
choices,
|
|
46
|
+
});
|
|
47
|
+
return initOpt === "new" ? initNewCodebase(setup, config) : overwriteCodebase(setup, config);
|
|
48
|
+
}
|
|
49
|
+
exports.doSetup = doSetup;
|
|
50
|
+
async function initNewCodebase(setup, config) {
|
|
51
|
+
logger_1.logger.info("Let's create a new codebase for your functions.");
|
|
52
|
+
logger_1.logger.info("A directory corresponding to the codebase will be created in your project");
|
|
53
|
+
logger_1.logger.info("with sample code pre-configured.\n");
|
|
54
|
+
logger_1.logger.info("See https://firebase.google.com/docs/functions/organize-functions for");
|
|
55
|
+
logger_1.logger.info("more information on organizing your functions using codebases.\n");
|
|
56
|
+
logger_1.logger.info(`Functions can be deployed with ${clc.bold("firebase deploy")}.\n`);
|
|
57
|
+
let source;
|
|
58
|
+
let codebase;
|
|
59
|
+
if (setup.config.functions.length === 0) {
|
|
60
|
+
source = "functions";
|
|
61
|
+
codebase = "default";
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
let attempts = 0;
|
|
65
|
+
while (true) {
|
|
66
|
+
if (attempts++ >= MAX_ATTEMPTS) {
|
|
67
|
+
throw new error_1.FirebaseError("Exceeded max number of attempts to input valid codebase name. Please restart.");
|
|
68
|
+
}
|
|
69
|
+
codebase = await (0, prompt_1.promptOnce)({
|
|
70
|
+
type: "input",
|
|
71
|
+
message: "What should be the name of this codebase?",
|
|
72
|
+
});
|
|
73
|
+
try {
|
|
74
|
+
(0, projectConfig_1.validateCodebase)(codebase);
|
|
75
|
+
(0, projectConfig_1.assertUnique)(setup.config.functions, "codebase", codebase);
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
logger_1.logger.error(err);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
attempts = 0;
|
|
83
|
+
while (true) {
|
|
84
|
+
if (attempts >= MAX_ATTEMPTS) {
|
|
85
|
+
throw new error_1.FirebaseError("Exceeded max number of attempts to input valid source. Please restart.");
|
|
86
|
+
}
|
|
87
|
+
attempts++;
|
|
88
|
+
source = await (0, prompt_1.promptOnce)({
|
|
89
|
+
type: "input",
|
|
90
|
+
message: `In what sub-directory would you like to initialize your functions for codebase ${clc.bold(codebase)}?`,
|
|
91
|
+
default: codebase,
|
|
92
|
+
});
|
|
93
|
+
try {
|
|
94
|
+
(0, projectConfig_1.assertUnique)(setup.config.functions, "source", source);
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
catch (err) {
|
|
98
|
+
logger_1.logger.error(err);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
setup.config.functions.push({
|
|
103
|
+
source,
|
|
104
|
+
codebase,
|
|
105
|
+
});
|
|
106
|
+
setup.functions.source = source;
|
|
107
|
+
setup.functions.codebase = codebase;
|
|
108
|
+
return languageSetup(setup, config);
|
|
109
|
+
}
|
|
110
|
+
async function overwriteCodebase(setup, config) {
|
|
111
|
+
let codebase;
|
|
112
|
+
if (setup.config.functions.length > 1) {
|
|
113
|
+
const choices = setup.config.functions.map((cfg) => ({
|
|
114
|
+
name: cfg["codebase"],
|
|
115
|
+
value: cfg["codebase"],
|
|
116
|
+
}));
|
|
117
|
+
codebase = await (0, prompt_1.promptOnce)({
|
|
118
|
+
type: "list",
|
|
119
|
+
message: "Which codebase would you like to overwrite?",
|
|
120
|
+
choices,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
codebase = setup.config.functions[0].codebase;
|
|
125
|
+
}
|
|
126
|
+
const cbconfig = (0, projectConfig_1.configForCodebase)(setup.config.functions, codebase);
|
|
127
|
+
setup.functions.source = cbconfig.source;
|
|
128
|
+
setup.functions.codebase = cbconfig.codebase;
|
|
129
|
+
logger_1.logger.info(`\nOverwriting ${clc.bold(`codebase ${codebase}...\n`)}`);
|
|
130
|
+
return languageSetup(setup, config);
|
|
131
|
+
}
|
|
132
|
+
async function languageSetup(setup, config) {
|
|
26
133
|
const choices = [
|
|
27
134
|
{
|
|
28
135
|
name: "JavaScript",
|
|
@@ -45,12 +152,14 @@ async function doSetup(setup, config, options) {
|
|
|
45
152
|
default: "javascript",
|
|
46
153
|
choices,
|
|
47
154
|
});
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
"
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
155
|
+
const cbconfig = (0, projectConfig_1.configForCodebase)(setup.config.functions, setup.functions.codebase);
|
|
156
|
+
switch (language) {
|
|
157
|
+
case "javascript":
|
|
158
|
+
cbconfig.ignore = ["node_modules", ".git", "firebase-debug.log", "firebase-debug.*.log"];
|
|
159
|
+
break;
|
|
160
|
+
case "typescript":
|
|
161
|
+
cbconfig.ignore = ["node_modules", ".git", "firebase-debug.log", "firebase-debug.*.log"];
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
54
164
|
return require("./" + language).setup(setup, config);
|
|
55
165
|
}
|
|
56
|
-
exports.doSetup = doSetup;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.setup = void 0;
|
|
4
|
-
const _ = require("lodash");
|
|
5
4
|
const fs = require("fs");
|
|
6
5
|
const path = require("path");
|
|
7
6
|
const npm_dependencies_1 = require("./npm-dependencies");
|
|
8
7
|
const prompt_1 = require("../../../prompt");
|
|
8
|
+
const projectConfig_1 = require("../../../functions/projectConfig");
|
|
9
9
|
const TEMPLATE_ROOT = path.resolve(__dirname, "../../../../templates/init/functions/javascript/");
|
|
10
10
|
const INDEX_TEMPLATE = fs.readFileSync(path.join(TEMPLATE_ROOT, "index.js"), "utf8");
|
|
11
11
|
const PACKAGE_LINTING_TEMPLATE = fs.readFileSync(path.join(TEMPLATE_ROOT, "package.lint.json"), "utf8");
|
|
@@ -23,20 +23,21 @@ function setup(setup, config) {
|
|
|
23
23
|
])
|
|
24
24
|
.then(() => {
|
|
25
25
|
if (setup.functions.lint) {
|
|
26
|
-
|
|
26
|
+
const cbconfig = (0, projectConfig_1.configForCodebase)(setup.config.functions, setup.functions.codebase);
|
|
27
|
+
cbconfig.predeploy = ['npm --prefix "$RESOURCE_DIR" run lint'];
|
|
27
28
|
return config
|
|
28
|
-
.askWriteProjectFile(
|
|
29
|
+
.askWriteProjectFile(`${setup.functions.source}/package.json`, PACKAGE_LINTING_TEMPLATE)
|
|
29
30
|
.then(() => {
|
|
30
|
-
config.askWriteProjectFile(
|
|
31
|
+
config.askWriteProjectFile(`${setup.functions.source}/.eslintrc.js`, ESLINT_TEMPLATE);
|
|
31
32
|
});
|
|
32
33
|
}
|
|
33
|
-
return config.askWriteProjectFile(
|
|
34
|
+
return config.askWriteProjectFile(`${setup.functions.source}/package.json`, PACKAGE_NO_LINTING_TEMPLATE);
|
|
34
35
|
})
|
|
35
36
|
.then(() => {
|
|
36
|
-
return config.askWriteProjectFile(
|
|
37
|
+
return config.askWriteProjectFile(`${setup.functions.source}/index.js`, INDEX_TEMPLATE);
|
|
37
38
|
})
|
|
38
39
|
.then(() => {
|
|
39
|
-
return config.askWriteProjectFile(
|
|
40
|
+
return config.askWriteProjectFile(`${setup.functions.source}/.gitignore`, GITIGNORE_TEMPLATE);
|
|
40
41
|
})
|
|
41
42
|
.then(() => {
|
|
42
43
|
return (0, npm_dependencies_1.askInstallDependencies)(setup.functions, config);
|
|
@@ -16,7 +16,7 @@ function askInstallDependencies(setup, config) {
|
|
|
16
16
|
if (setup.npm) {
|
|
17
17
|
return new Promise((resolve) => {
|
|
18
18
|
const installer = spawn("npm", ["install"], {
|
|
19
|
-
cwd: config.projectDir +
|
|
19
|
+
cwd: config.projectDir + `/${setup.source}`,
|
|
20
20
|
stdio: "inherit",
|
|
21
21
|
});
|
|
22
22
|
installer.on("error", (err) => {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.setup = void 0;
|
|
4
|
-
const _ = require("lodash");
|
|
5
4
|
const fs = require("fs");
|
|
6
5
|
const path = require("path");
|
|
7
6
|
const npm_dependencies_1 = require("./npm-dependencies");
|
|
8
7
|
const prompt_1 = require("../../../prompt");
|
|
8
|
+
const projectConfig_1 = require("../../../functions/projectConfig");
|
|
9
9
|
const TEMPLATE_ROOT = path.resolve(__dirname, "../../../../templates/init/functions/typescript/");
|
|
10
10
|
const PACKAGE_LINTING_TEMPLATE = fs.readFileSync(path.join(TEMPLATE_ROOT, "package.lint.json"), "utf8");
|
|
11
11
|
const PACKAGE_NO_LINTING_TEMPLATE = fs.readFileSync(path.join(TEMPLATE_ROOT, "package.nolint.json"), "utf8");
|
|
@@ -24,33 +24,35 @@ function setup(setup, config) {
|
|
|
24
24
|
},
|
|
25
25
|
])
|
|
26
26
|
.then(() => {
|
|
27
|
+
const cbconfig = (0, projectConfig_1.configForCodebase)(setup.config.functions, setup.functions.codebase);
|
|
28
|
+
cbconfig.predeploy = [];
|
|
27
29
|
if (setup.functions.lint) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
'npm --prefix "$RESOURCE_DIR" run build',
|
|
31
|
-
]);
|
|
30
|
+
cbconfig.predeploy.push('npm --prefix "$RESOURCE_DIR" run lint');
|
|
31
|
+
cbconfig.predeploy.push('npm --prefix "$RESOURCE_DIR" run build');
|
|
32
32
|
return config
|
|
33
|
-
.askWriteProjectFile(
|
|
33
|
+
.askWriteProjectFile(`${setup.functions.source}/package.json`, PACKAGE_LINTING_TEMPLATE)
|
|
34
34
|
.then(() => {
|
|
35
|
-
return config.askWriteProjectFile(
|
|
35
|
+
return config.askWriteProjectFile(`${setup.functions.source}/.eslintrc.js`, ESLINT_TEMPLATE);
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
else {
|
|
39
|
+
cbconfig.predeploy.push('npm --prefix "$RESOURCE_DIR" run build');
|
|
40
|
+
}
|
|
41
|
+
return config.askWriteProjectFile(`${setup.functions.source}/package.json`, PACKAGE_NO_LINTING_TEMPLATE);
|
|
40
42
|
})
|
|
41
43
|
.then(() => {
|
|
42
|
-
return config.askWriteProjectFile(
|
|
44
|
+
return config.askWriteProjectFile(`${setup.functions.source}/tsconfig.json`, TSCONFIG_TEMPLATE);
|
|
43
45
|
})
|
|
44
46
|
.then(() => {
|
|
45
47
|
if (setup.functions.lint) {
|
|
46
|
-
return config.askWriteProjectFile(
|
|
48
|
+
return config.askWriteProjectFile(`${setup.functions.source}/tsconfig.dev.json`, TSCONFIG_DEV_TEMPLATE);
|
|
47
49
|
}
|
|
48
50
|
})
|
|
49
51
|
.then(() => {
|
|
50
|
-
return config.askWriteProjectFile(
|
|
52
|
+
return config.askWriteProjectFile(`${setup.functions.source}/src/index.ts`, INDEX_TEMPLATE);
|
|
51
53
|
})
|
|
52
54
|
.then(() => {
|
|
53
|
-
return config.askWriteProjectFile(
|
|
55
|
+
return config.askWriteProjectFile(`${setup.functions.source}/.gitignore`, GITIGNORE_TEMPLATE);
|
|
54
56
|
})
|
|
55
57
|
.then(() => {
|
|
56
58
|
return (0, npm_dependencies_1.askInstallDependencies)(setup.functions, config);
|