@simondotm/nx-firebase 1.1.0-beta.0 → 2.0.0-beta.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/README.md +10 -10
- package/executors.json +0 -8
- package/generators.json +11 -0
- package/package.json +7 -4
- package/src/generators/application/application.d.ts +3 -3
- package/src/generators/application/application.js +119 -19
- package/src/generators/application/application.js.map +1 -1
- package/src/generators/application/files/readme.md__tmpl__ +12 -9
- package/src/generators/application/files_firebase/firebase.json__tmpl__ +6 -13
- package/src/generators/application/files_workspace/{firebase.__name__.json__tmpl__ → firebase.__projectName__.json__tmpl__} +6 -13
- package/src/generators/application/lib/create-files.js +10 -25
- package/src/generators/application/lib/create-files.js.map +1 -1
- package/src/generators/application/lib/index.d.ts +0 -3
- package/src/generators/application/lib/index.js +0 -3
- package/src/generators/application/lib/index.js.map +1 -1
- package/src/generators/application/schema.d.ts +3 -11
- package/src/generators/application/schema.json +0 -41
- package/src/generators/function/files/package.json__tmpl__ +19 -0
- package/src/generators/function/files/readme.md__tmpl__ +31 -0
- package/src/generators/function/function.d.ts +14 -0
- package/src/generators/function/function.js +77 -0
- package/src/generators/function/function.js.map +1 -0
- package/src/generators/function/lib/add-function.d.ts +3 -0
- package/src/generators/function/lib/add-function.js +25 -0
- package/src/generators/function/lib/add-function.js.map +1 -0
- package/src/generators/function/lib/create-files.d.ts +9 -0
- package/src/generators/function/lib/create-files.js +37 -0
- package/src/generators/function/lib/create-files.js.map +1 -0
- package/src/generators/{application → function}/lib/delete-files.d.ts +1 -1
- package/src/generators/{application → function}/lib/delete-files.js +1 -1
- package/src/generators/function/lib/delete-files.js.map +1 -0
- package/src/generators/function/lib/index.d.ts +3 -0
- package/src/generators/function/lib/index.js +7 -0
- package/src/generators/function/lib/index.js.map +1 -0
- package/src/generators/function/lib/update-project.d.ts +3 -0
- package/src/generators/function/lib/update-project.js +52 -0
- package/src/generators/function/lib/update-project.js.map +1 -0
- package/src/generators/function/schema.d.ts +51 -0
- package/src/generators/function/schema.json +57 -0
- package/src/generators/init/init.js +1 -5
- package/src/generators/init/init.js.map +1 -1
- package/src/generators/init/lib/add-dependencies.js +3 -4
- package/src/generators/init/lib/add-dependencies.js.map +1 -1
- package/src/generators/init/lib/add-git-ignore-entry.d.ts +1 -1
- package/src/generators/init/lib/add-git-ignore-entry.js +1 -0
- package/src/generators/init/lib/add-git-ignore-entry.js.map +1 -1
- package/src/generators/init/schema.d.ts +4 -4
- package/src/generators/init/schema.json +8 -7
- package/src/generators/sync/lib/firebase-changes.d.ts +3 -0
- package/src/generators/sync/lib/firebase-changes.js +102 -0
- package/src/generators/sync/lib/firebase-changes.js.map +1 -0
- package/src/generators/sync/lib/firebase-configs.d.ts +3 -0
- package/src/generators/sync/lib/firebase-configs.js +61 -0
- package/src/generators/sync/lib/firebase-configs.js.map +1 -0
- package/src/generators/sync/lib/firebase-projects.d.ts +20 -0
- package/src/generators/sync/lib/firebase-projects.js +75 -0
- package/src/generators/sync/lib/firebase-projects.js.map +1 -0
- package/src/generators/sync/lib/firebase-workspace.d.ts +3 -0
- package/src/generators/sync/lib/firebase-workspace.js +15 -0
- package/src/generators/sync/lib/firebase-workspace.js.map +1 -0
- package/src/generators/sync/lib/index.d.ts +7 -0
- package/src/generators/sync/lib/index.js +11 -0
- package/src/generators/sync/lib/index.js.map +1 -0
- package/src/generators/sync/lib/tags.d.ts +14 -0
- package/src/generators/sync/lib/tags.js +43 -0
- package/src/generators/sync/lib/tags.js.map +1 -0
- package/src/generators/sync/lib/types.d.ts +46 -0
- package/src/generators/sync/lib/types.js +5 -0
- package/src/generators/sync/lib/types.js.map +1 -0
- package/src/generators/sync/schema.d.ts +5 -0
- package/src/generators/sync/schema.json +19 -0
- package/src/generators/sync/sync.d.ts +8 -0
- package/src/generators/sync/sync.js +167 -0
- package/src/generators/sync/sync.js.map +1 -0
- package/src/utils/debug.d.ts +4 -0
- package/src/utils/debug.js +25 -0
- package/src/utils/debug.js.map +1 -0
- package/src/utils/firebase-config.d.ts +77 -0
- package/src/utils/firebase-config.js +52 -0
- package/src/utils/firebase-config.js.map +1 -0
- package/src/utils/index.d.ts +3 -0
- package/src/utils/index.js +3 -0
- package/src/utils/index.js.map +1 -1
- package/src/utils/project-name.d.ts +5 -0
- package/src/utils/project-name.js +38 -0
- package/src/utils/project-name.js.map +1 -0
- package/src/utils/update-tsconfig.d.ts +8 -0
- package/src/{generators/application/lib → utils}/update-tsconfig.js +5 -5
- package/src/utils/update-tsconfig.js.map +1 -0
- package/src/utils/versions.d.ts +1 -0
- package/src/utils/versions.js +5 -4
- package/src/utils/versions.js.map +1 -1
- package/src/executors/build/build.d.ts +0 -8
- package/src/executors/build/build.js +0 -82
- package/src/executors/build/build.js.map +0 -1
- package/src/executors/build/lib/copy-dependencies.d.ts +0 -3
- package/src/executors/build/lib/copy-dependencies.js +0 -53
- package/src/executors/build/lib/copy-dependencies.js.map +0 -1
- package/src/executors/build/lib/firebase-build.d.ts +0 -2
- package/src/executors/build/lib/firebase-build.js +0 -16
- package/src/executors/build/lib/firebase-build.js.map +0 -1
- package/src/executors/build/lib/get-dependencies.d.ts +0 -8
- package/src/executors/build/lib/get-dependencies.js +0 -87
- package/src/executors/build/lib/get-dependencies.js.map +0 -1
- package/src/executors/build/lib/index.d.ts +0 -1
- package/src/executors/build/lib/index.js +0 -5
- package/src/executors/build/lib/index.js.map +0 -1
- package/src/executors/build/lib/rewrite-package.d.ts +0 -8
- package/src/executors/build/lib/rewrite-package.js +0 -44
- package/src/executors/build/lib/rewrite-package.js.map +0 -1
- package/src/executors/build/schema.d.ts +0 -1
- package/src/executors/build/schema.json +0 -167
- package/src/generators/application/files/package.json__tmpl__ +0 -21
- package/src/generators/application/lib/add-project.d.ts +0 -39
- package/src/generators/application/lib/add-project.js +0 -115
- package/src/generators/application/lib/add-project.js.map +0 -1
- package/src/generators/application/lib/delete-files.js.map +0 -1
- package/src/generators/application/lib/normalize-options.d.ts +0 -5
- package/src/generators/application/lib/normalize-options.js +0 -44
- package/src/generators/application/lib/normalize-options.js.map +0 -1
- package/src/generators/application/lib/update-tsconfig.d.ts +0 -9
- package/src/generators/application/lib/update-tsconfig.js.map +0 -1
- package/src/utils/e2ePatch.d.ts +0 -2
- package/src/utils/e2ePatch.js +0 -135
- package/src/utils/e2ePatch.js.map +0 -1
- /package/src/generators/{application/files/src/index.ts__tmpl__ → function/files/src/main.ts__tmpl__} +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { GeneratorCallback, Tree } from '@nrwl/devkit';
|
|
2
|
+
import type { FunctionGeneratorOptions, NormalizedOptions } from './schema';
|
|
3
|
+
export declare function normalizeOptions(tree: Tree, options: FunctionGeneratorOptions): NormalizedOptions;
|
|
4
|
+
/**
|
|
5
|
+
* Firebase 'functions' application generator
|
|
6
|
+
* Uses the `@nrwl/node` application generator as a base implementation
|
|
7
|
+
*
|
|
8
|
+
* @param tree
|
|
9
|
+
* @param rawOptions
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
export declare function functionGenerator(tree: Tree, rawOptions: FunctionGeneratorOptions): Promise<GeneratorCallback>;
|
|
13
|
+
export default functionGenerator;
|
|
14
|
+
export declare const functionSchematic: (generatorOptions: FunctionGeneratorOptions) => (tree: any, context: any) => Promise<any>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.functionSchematic = exports.functionGenerator = exports.normalizeOptions = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const devkit_1 = require("@nrwl/devkit");
|
|
6
|
+
const node_1 = require("@nrwl/node");
|
|
7
|
+
const init_1 = require("../init/init");
|
|
8
|
+
const utils_1 = require("../../utils");
|
|
9
|
+
const lib_1 = require("./lib");
|
|
10
|
+
function normalizeOptions(tree, options) {
|
|
11
|
+
const { projectName, projectRoot } = (0, utils_1.getProjectName)(tree, options.name, options.directory);
|
|
12
|
+
// get & validate the firebase app project this function will be attached to
|
|
13
|
+
const firebaseApp = (0, devkit_1.names)(options.app).fileName;
|
|
14
|
+
const projects = (0, devkit_1.getProjects)(tree);
|
|
15
|
+
if (!projects.has(firebaseApp)) {
|
|
16
|
+
throw new Error(`A firebase application project called '${firebaseApp}' was not found in this workspace.`);
|
|
17
|
+
}
|
|
18
|
+
const firebaseAppProject = (0, devkit_1.readProjectConfiguration)(tree, firebaseApp);
|
|
19
|
+
// read the firebase config used by the parent app project
|
|
20
|
+
const firebaseConfigName = (0, utils_1.getFirebaseConfigFromProject)(tree, firebaseAppProject);
|
|
21
|
+
return Object.assign(Object.assign({}, options), { runTime: options.runTime || '16', format: options.format || 'esm', projectRoot,
|
|
22
|
+
projectName,
|
|
23
|
+
firebaseConfigName,
|
|
24
|
+
firebaseAppProject });
|
|
25
|
+
}
|
|
26
|
+
exports.normalizeOptions = normalizeOptions;
|
|
27
|
+
/**
|
|
28
|
+
* Firebase 'functions' application generator
|
|
29
|
+
* Uses the `@nrwl/node` application generator as a base implementation
|
|
30
|
+
*
|
|
31
|
+
* @param tree
|
|
32
|
+
* @param rawOptions
|
|
33
|
+
* @returns
|
|
34
|
+
*/
|
|
35
|
+
function functionGenerator(tree, rawOptions) {
|
|
36
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const tasks = [];
|
|
38
|
+
const options = normalizeOptions(tree, rawOptions);
|
|
39
|
+
// initialise plugin
|
|
40
|
+
const initTask = yield (0, init_1.initGenerator)(tree, {});
|
|
41
|
+
tasks.push(initTask);
|
|
42
|
+
// We use @nx/node:app to scaffold our function application, then modify as required
|
|
43
|
+
// `nx g @nx/node:app function-name --directory functions/dir --e2eTestRunner=none --framework=none --unitTestRunner=jest --bundler=esbuild --tags=firebase:firebase-app`
|
|
44
|
+
// Function apps are tagged so that they can built/watched with run-many
|
|
45
|
+
const tags = `firebase:function,firebase:name:${options.projectName},firebase:dep:${options.firebaseAppProject.name}` +
|
|
46
|
+
(options.tags ? `,${options.tags}` : '');
|
|
47
|
+
const nodeApplicationTask = yield (0, node_1.applicationGenerator)(tree, {
|
|
48
|
+
name: options.name,
|
|
49
|
+
directory: options.directory,
|
|
50
|
+
tags,
|
|
51
|
+
setParserOptionsProject: options.setParserOptionsProject,
|
|
52
|
+
skipFormat: options.skipFormat,
|
|
53
|
+
e2eTestRunner: 'none',
|
|
54
|
+
bundler: 'esbuild',
|
|
55
|
+
framework: 'none',
|
|
56
|
+
unitTestRunner: 'jest',
|
|
57
|
+
});
|
|
58
|
+
tasks.push(nodeApplicationTask);
|
|
59
|
+
// generate function app specific files
|
|
60
|
+
(0, lib_1.createFiles)(tree, options);
|
|
61
|
+
// update TS config for esm or cjs
|
|
62
|
+
(0, utils_1.updateTsConfig)(tree, options.projectRoot, options.runTime, options.format);
|
|
63
|
+
// reconfigure the @nx/node:app to suit firebase functions
|
|
64
|
+
(0, lib_1.updateProject)(tree, options);
|
|
65
|
+
// update firebase functions config
|
|
66
|
+
(0, lib_1.addFunction)(tree, options);
|
|
67
|
+
// ensures newly added files are formatted to match workspace style
|
|
68
|
+
if (!options.skipFormat) {
|
|
69
|
+
yield (0, devkit_1.formatFiles)(tree);
|
|
70
|
+
}
|
|
71
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
exports.functionGenerator = functionGenerator;
|
|
75
|
+
exports.default = functionGenerator;
|
|
76
|
+
exports.functionSchematic = (0, devkit_1.convertNxGenerator)(functionGenerator);
|
|
77
|
+
//# sourceMappingURL=function.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function.js","sourceRoot":"","sources":["../../../../../../packages/nx-firebase/src/generators/function/function.ts"],"names":[],"mappings":";;;;AAAA,yCASqB;AACrB,qCAA6E;AAE7E,uCAA4C;AAC5C,uCAIoB;AAEpB,+BAA+D;AAG/D,SAAgB,gBAAgB,CAC9B,IAAU,EACV,OAAiC;IAEjC,MA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perty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addFunction = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
function addFunction(tree, options) {
|
|
6
|
+
(0, devkit_1.updateJson)(tree, options.firebaseConfigName, (json) => {
|
|
7
|
+
const functionConfig = {
|
|
8
|
+
codebase: options.projectName,
|
|
9
|
+
source: (0, devkit_1.joinPathFragments)('dist', options.projectRoot),
|
|
10
|
+
runtime: `nodejs${options.runTime}`,
|
|
11
|
+
};
|
|
12
|
+
// console.log(`json.functions=${JSON.stringify(json.functions)}`)
|
|
13
|
+
if (!Array.isArray(json.functions)) {
|
|
14
|
+
const existingFunction = Object.assign({}, json.functions);
|
|
15
|
+
json.functions = [];
|
|
16
|
+
if (Object.keys(existingFunction).length) {
|
|
17
|
+
json.functions.push(existingFunction);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
json.functions.push(functionConfig);
|
|
21
|
+
return json;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
exports.addFunction = addFunction;
|
|
25
|
+
//# sourceMappingURL=add-function.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-function.js","sourceRoot":"","sources":["../../../../../../../packages/nx-firebase/src/generators/function/lib/add-function.ts"],"names":[],"mappings":";;;AAAA,uCAAgE;AAIhE,SAAgB,WAAW,CAAC,IAAU,EAAE,OAA0B;IAChE,IAAA,mBAAU,EAAC,IAAI,EAAE,OAAO,CAAC,kBAAkB,EAAE,CAAC,IAAoB,EAAE,EAAE;QACpE,MAAM,cAAc,GAAG;YACrB,QAAQ,EAAE,OAAO,CAAC,WAAW;YAC7B,MAAM,EAAE,IAAA,0BAAiB,EAAC,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC;YACtD,OAAO,EAAE,SAAS,OAAO,CAAC,OAAO,EAAE;SACpC,CAAA;QAED,kEAAkE;QAClE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;YAClC,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,SAAS,CAAC,CAAA;YAC1D,IAAI,CAAC,SAAS,GAAG,EAAE,CAAA;YACnB,IAAI,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,MAAM,EAAE;gBACxC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAA;aACtC;SACF;QACD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;QACnC,OAAO,IAAI,CAAA;IACb,CAAC,CAAC,CAAA;AACJ,CAAC;AAnBD,kCAmBC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Tree } from '@nrwl/devkit';
|
|
2
|
+
import type { NormalizedOptions } from '../schema';
|
|
3
|
+
/**
|
|
4
|
+
* Generate the firebase app specific files
|
|
5
|
+
*
|
|
6
|
+
* @param tree
|
|
7
|
+
* @param options
|
|
8
|
+
*/
|
|
9
|
+
export declare function createFiles(tree: Tree, options: NormalizedOptions): void;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createFiles = void 0;
|
|
4
|
+
const devkit_1 = require("@nrwl/devkit");
|
|
5
|
+
const devkit_2 = require("@nrwl/devkit");
|
|
6
|
+
/**
|
|
7
|
+
* Generate the firebase app specific files
|
|
8
|
+
*
|
|
9
|
+
* @param tree
|
|
10
|
+
* @param options
|
|
11
|
+
*/
|
|
12
|
+
function createFiles(tree, options) {
|
|
13
|
+
const firebaseAppConfig = options.firebaseConfigName;
|
|
14
|
+
const firebaseAppConfigPath = (0, devkit_2.joinPathFragments)((0, devkit_1.offsetFromRoot)(options.projectRoot), firebaseAppConfig);
|
|
15
|
+
const substitutions = {
|
|
16
|
+
tmpl: '',
|
|
17
|
+
projectName: options.projectName,
|
|
18
|
+
projectRoot: options.projectRoot,
|
|
19
|
+
firebaseAppName: options.app,
|
|
20
|
+
firebaseAppConfig,
|
|
21
|
+
firebaseAppConfigPath,
|
|
22
|
+
firebaseNodeEngine: options.runTime,
|
|
23
|
+
// firebaseNodeRuntime,
|
|
24
|
+
// firebaseNodeEngine,
|
|
25
|
+
moduleType: options.format === 'esm' ? 'module' : 'commonjs',
|
|
26
|
+
};
|
|
27
|
+
// The default functions package.json & templated typescript source files are added here
|
|
28
|
+
// to match the `firebase init` cli setup
|
|
29
|
+
// if the user isn't using functions, they can just delete and update their firebase config accordingly
|
|
30
|
+
//
|
|
31
|
+
// Rules and index files also get generated in the application folder;
|
|
32
|
+
// 1. so that they dont clutter up the root workspace
|
|
33
|
+
// 2. so that they are located within the nx firebase application project they relate to
|
|
34
|
+
(0, devkit_2.generateFiles)(tree, (0, devkit_2.joinPathFragments)(__dirname, '..', 'files'), options.projectRoot, substitutions);
|
|
35
|
+
}
|
|
36
|
+
exports.createFiles = createFiles;
|
|
37
|
+
//# sourceMappingURL=create-files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-files.js","sourceRoot":"","sources":["../../../../../../../packages/nx-firebase/src/generators/function/lib/create-files.ts"],"names":[],"mappings":";;;AAAA,yCAAmD;AACnD,yCAA+D;AAI/D;;;;;GAKG;AACH,SAAgB,WAAW,CAAC,IAAU,EAAE,OAA0B;IAChE,MAAM,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAA;IACpD,MAAM,qBAAqB,GAAG,IAAA,0BAAiB,EAC7C,IAAA,uBAAc,EAAC,OAAO,CAAC,WAAW,CAAC,EACnC,iBAAiB,CAClB,CAAA;IAED,MAAM,aAAa,GAAG;QACpB,IAAI,EAAE,EAAE;QACR,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,WAAW,EAAE,OAAO,CAAC,WAAW;QAEhC,eAAe,EAAE,OAAO,CAAC,GAAG;QAC5B,iBAAiB;QACjB,qBAAqB;QAErB,kBAAkB,EAAE,OAAO,CAAC,OAAO;QAEnC,uBAAuB;QACvB,sBAAsB;QAEtB,UAAU,EAAE,OAAO,CAAC,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU;KAC7D,CAAA;IAED,wFAAwF;IACxF,yCAAyC;IACzC,uGAAuG;IACvG,EAAE;IACF,sEAAsE;IACtE,qDAAqD;IACrD,wFAAwF;IACxF,IAAA,sBAAa,EACX,IAAI,EACJ,IAAA,0BAAiB,EAAC,SAAS,EAAE,IAAI,EAAE,OAAO,CAAC,EAC3C,OAAO,CAAC,WAAW,EACnB,aAAa,CACd,CAAA;AACH,CAAC;AArCD,kCAqCC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.deleteFiles = void 0;
|
|
4
|
-
const devkit_1 = require("@
|
|
4
|
+
const devkit_1 = require("@nrwl/devkit");
|
|
5
5
|
/**
|
|
6
6
|
* Delete unwanted files created by the node generator
|
|
7
7
|
* @param tree
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-files.js","sourceRoot":"","sources":["../../../../../../../packages/nx-firebase/src/generators/function/lib/delete-files.ts"],"names":[],"mappings":";;;AACA,yCAAgD;AAGhD;;;;GAIG;AACH,SAAgB,WAAW,CAAC,IAAU,EAAE,OAA0B;IAChE,MAAM,iBAAiB,GAAG;QACxB,IAAA,0BAAiB,EAAC,OAAO,CAAC,WAAW,EAAE,KAAK,EAAE,SAAS,CAAC;QACxD,IAAA,0BAAiB,EAAC,OAAO,CAAC,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,CAAC;QAChE,IAAA,0BAAiB,EAAC,OAAO,CAAC,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,CAAC;QACnE,IAAA,0BAAiB,EACf,OAAO,CAAC,WAAW,EACnB,KAAK,EACL,cAAc,EACd,qBAAqB,CACtB;QACD,IAAA,0BAAiB,EACf,OAAO,CAAC,WAAW,EACnB,KAAK,EACL,cAAc,EACd,gBAAgB,CACjB;KACF,CAAA;IAED,KAAK,MAAM,IAAI,IAAI,iBAAiB,EAAE;QACpC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;KAClB;AACH,CAAC;AAtBD,kCAsBC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./add-function"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./create-files"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./update-project"), exports);
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/nx-firebase/src/generators/function/lib/index.ts"],"names":[],"mappings":";;;AAAA,yDAA8B;AAC9B,yDAA8B;AAC9B,2DAAgC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateProject = void 0;
|
|
4
|
+
const devkit_1 = require("@nrwl/devkit");
|
|
5
|
+
function updateProject(tree, options) {
|
|
6
|
+
const project = (0, devkit_1.readProjectConfiguration)(tree, options.projectName);
|
|
7
|
+
const firebaseAppProject = options.firebaseAppProject;
|
|
8
|
+
// replace the default node build target with a simplified version
|
|
9
|
+
// we dont need dev/production build configurations for firebase functions since its a confined secure environment
|
|
10
|
+
project.targets.build = {
|
|
11
|
+
executor: '@nx/esbuild:esbuild',
|
|
12
|
+
outputs: ['{options.outputPath}'],
|
|
13
|
+
options: {
|
|
14
|
+
outputPath: project.targets.build.options.outputPath,
|
|
15
|
+
main: project.targets.build.options.main,
|
|
16
|
+
tsConfig: project.targets.build.options.tsConfig,
|
|
17
|
+
assets: project.targets.build.options.assets,
|
|
18
|
+
generatePackageJson: true,
|
|
19
|
+
// these are the defaults for esbuild, but let's set them anyway
|
|
20
|
+
platform: 'node',
|
|
21
|
+
bundle: true,
|
|
22
|
+
thirdParty: false,
|
|
23
|
+
dependenciesFieldType: 'dependencies',
|
|
24
|
+
target: 'node16',
|
|
25
|
+
format: [options.format || 'esm'],
|
|
26
|
+
esbuildOptions: {
|
|
27
|
+
logLevel: 'info',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
project.targets.deploy = {
|
|
32
|
+
executor: 'nx:run-commands',
|
|
33
|
+
options: {
|
|
34
|
+
// command: `firebase deploy${firebaseProject} --config=${firebaseConfig}`,
|
|
35
|
+
// use the firebase app to deploy, this way the function does not need to know the project or config
|
|
36
|
+
command: `nx run ${firebaseAppProject.name}:deploy --only functions:${options.projectName}`,
|
|
37
|
+
},
|
|
38
|
+
dependsOn: ['build'],
|
|
39
|
+
};
|
|
40
|
+
// Remove default node app serve target
|
|
41
|
+
// No serve target for functions, since we may have multiple functions in a firebase project
|
|
42
|
+
// Instead we serve at the firebase app project
|
|
43
|
+
delete project.targets.serve;
|
|
44
|
+
(0, devkit_1.updateProjectConfiguration)(tree, options.projectName, project);
|
|
45
|
+
// Add function project as implicit dep of firebase app project
|
|
46
|
+
firebaseAppProject.implicitDependencies || (firebaseAppProject.implicitDependencies = []);
|
|
47
|
+
firebaseAppProject.implicitDependencies.push(options.projectName);
|
|
48
|
+
firebaseAppProject.implicitDependencies.sort();
|
|
49
|
+
(0, devkit_1.updateProjectConfiguration)(tree, options.app, firebaseAppProject);
|
|
50
|
+
}
|
|
51
|
+
exports.updateProject = updateProject;
|
|
52
|
+
//# sourceMappingURL=update-project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-project.js","sourceRoot":"","sources":["../../../../../../../packages/nx-firebase/src/generators/function/lib/update-project.ts"],"names":[],"mappings":";;;AAA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C,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAA;IAE5B,IAAA,mCAA0B,EAAC,IAAI,EAAE,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,CAAA;IAE9D,+DAA+D;IAC/D,kBAAkB,CAAC,oBAAoB,KAAvC,kBAAkB,CAAC,oBAAoB,GAAK,EAAE,EAAA;IAC9C,kBAAkB,CAAC,oBAAoB,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;IACjE,kBAAkB,CAAC,oBAAoB,CAAC,IAAI,EAAE,CAAA;IAC9C,IAAA,mCAA0B,EAAC,IAAI,EAAE,OAAO,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAA;AACnE,CAAC;AAlDD,sCAkDC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ProjectConfiguration } from '@nx/devkit'
|
|
2
|
+
|
|
3
|
+
// export interface Schema {
|
|
4
|
+
// name: string;
|
|
5
|
+
// skipFormat?: boolean;
|
|
6
|
+
// skipPackageJson?: boolean;
|
|
7
|
+
// directory?: string;
|
|
8
|
+
// unitTestRunner?: 'jest' | 'none';
|
|
9
|
+
// e2eTestRunner?: 'jest' | 'none';
|
|
10
|
+
// linter?: Linter;
|
|
11
|
+
// tags?: string;
|
|
12
|
+
// frontendProject?: string;
|
|
13
|
+
// babelJest?: boolean;
|
|
14
|
+
// js?: boolean;
|
|
15
|
+
// pascalCaseFiles?: boolean;
|
|
16
|
+
// setParserOptionsProject?: boolean;
|
|
17
|
+
// standaloneConfig?: boolean;
|
|
18
|
+
// bundler?: 'esbuild' | 'webpack';
|
|
19
|
+
// framework?: NodeJsFrameWorks;
|
|
20
|
+
// port?: number;
|
|
21
|
+
// rootProject?: boolean;
|
|
22
|
+
// docker?: boolean;
|
|
23
|
+
// isNest?: boolean;
|
|
24
|
+
// }
|
|
25
|
+
|
|
26
|
+
// subset of @nx/node:application options that we forward to node app generator
|
|
27
|
+
interface SupportedNodeGeneratorOptions {
|
|
28
|
+
setParserOptionsProject?: boolean
|
|
29
|
+
skipFormat?: boolean
|
|
30
|
+
// unitTestRunner is always jest
|
|
31
|
+
// bundler is always esbuild
|
|
32
|
+
// linter is always eslint
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface FunctionGeneratorOptions
|
|
36
|
+
extends SupportedNodeGeneratorOptions {
|
|
37
|
+
name: string
|
|
38
|
+
directory?: string
|
|
39
|
+
tags?: string
|
|
40
|
+
|
|
41
|
+
app: string
|
|
42
|
+
runTime?: '16' | '18' | '20'
|
|
43
|
+
format?: 'esm' | 'cjs'
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface NormalizedOptions extends FunctionGeneratorOptions {
|
|
47
|
+
projectRoot: Path
|
|
48
|
+
projectName: string
|
|
49
|
+
firebaseConfigName: string
|
|
50
|
+
firebaseAppProject: ProjectConfiguration
|
|
51
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "NxFirebaseFunctionGenerator",
|
|
4
|
+
"title": "Nx Firebase Function Options Schema",
|
|
5
|
+
"description": "Nx Firebase Function Options Schema.",
|
|
6
|
+
"cli": "nx",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"name": {
|
|
10
|
+
"description": "The name of the firebase function project.",
|
|
11
|
+
"type": "string",
|
|
12
|
+
"$default": {
|
|
13
|
+
"$source": "argv",
|
|
14
|
+
"index": 0
|
|
15
|
+
},
|
|
16
|
+
"x-prompt": "What name would you like to use for the firebase function project?"
|
|
17
|
+
},
|
|
18
|
+
"directory": {
|
|
19
|
+
"description": "The directory of the new function project.",
|
|
20
|
+
"type": "string"
|
|
21
|
+
},
|
|
22
|
+
"tags": {
|
|
23
|
+
"description": "Add tags to the application (used for linting).",
|
|
24
|
+
"type": "string"
|
|
25
|
+
},
|
|
26
|
+
"setParserOptionsProject": {
|
|
27
|
+
"type": "boolean",
|
|
28
|
+
"description": "Whether or not to configure the ESLint `parserOptions.project` option. We do not do this by default for lint performance reasons.",
|
|
29
|
+
"default": false
|
|
30
|
+
},
|
|
31
|
+
"skipFormat": {
|
|
32
|
+
"description": "Skip formatting files.",
|
|
33
|
+
"type": "boolean",
|
|
34
|
+
"default": false
|
|
35
|
+
},
|
|
36
|
+
"format": {
|
|
37
|
+
"description": "The module format for this function (esm or cjs).",
|
|
38
|
+
"type": "string",
|
|
39
|
+
"enum": ["esm", "cjs"],
|
|
40
|
+
"default": "esm"
|
|
41
|
+
},
|
|
42
|
+
"app": {
|
|
43
|
+
"description": "The name of the parent Nx firebase application project this function will be added to.",
|
|
44
|
+
"type": "string",
|
|
45
|
+
"x-prompt": "Which firebase Nx application project will this function be created for?"
|
|
46
|
+
},
|
|
47
|
+
"runTime": {
|
|
48
|
+
"description": "The node runtime target for this function.",
|
|
49
|
+
"type": "string",
|
|
50
|
+
"enum": ["16", "18", "20"],
|
|
51
|
+
"default": "16"
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
},
|
|
55
|
+
"additionalProperties": false,
|
|
56
|
+
"required": ["name", "app"]
|
|
57
|
+
}
|
|
@@ -4,7 +4,6 @@ exports.initSchematic = exports.initGenerator = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const node_1 = require("@nx/node");
|
|
7
|
-
// import { runTasksInSerial } from '@nx/workspace/src/utilities/run-tasks-in-serial'
|
|
8
7
|
const lib_1 = require("./lib");
|
|
9
8
|
const add_git_ignore_entry_1 = require("./lib/add-git-ignore-entry");
|
|
10
9
|
/**
|
|
@@ -19,13 +18,10 @@ const add_git_ignore_entry_1 = require("./lib/add-git-ignore-entry");
|
|
|
19
18
|
*/
|
|
20
19
|
function initGenerator(tree, rawOptions) {
|
|
21
20
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
(0, add_git_ignore_entry_1.addGitIgnoreEntry)(tree);
|
|
23
21
|
const options = (0, lib_1.normalizeOptions)(rawOptions);
|
|
24
22
|
const nodeInitTask = yield (0, node_1.initGenerator)(tree, options);
|
|
25
23
|
const installPackagesTask = (0, lib_1.addDependencies)(tree);
|
|
26
|
-
|
|
27
|
-
yield (0, devkit_1.formatFiles)(tree);
|
|
28
|
-
}
|
|
24
|
+
(0, add_git_ignore_entry_1.addGitIgnoreEntry)(tree);
|
|
29
25
|
return (0, devkit_1.runTasksInSerial)(nodeInitTask, installPackagesTask);
|
|
30
26
|
});
|
|
31
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../../../../packages/nx-firebase/src/generators/init/init.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../../../../packages/nx-firebase/src/generators/init/init.ts"],"names":[],"mappings":";;;;AACA,uCAA8E;AAC9E,mCAA6D;AAC7D,+BAAyD;AACzD,qEAA8D;AAG9D;;;;;;;;;GASG;AACH,SAAsB,aAAa,CACjC,IAAU,EACV,UAAgC;;QAEhC,MAAM,OAAO,GAAG,IAAA,sBAAgB,EAAC,UAAU,CAAC,CAAA;QAC5C,MAAM,YAAY,GAAG,MAAM,IAAA,oBAAiB,EAAC,IAAI,EAAE,OAAO,CAAC,CAAA;QAC3D,MAAM,mBAAmB,GAAG,IAAA,qBAAe,EAAC,IAAI,CAAC,CAAA;QACjD,IAAA,wCAAiB,EAAC,IAAI,CAAC,CAAA;QAEvB,OAAO,IAAA,yBAAgB,EAAC,YAAY,EAAE,mBAAmB,CAAC,CAAA;IAC5D,CAAC;CAAA;AAVD,sCAUC;AAED,kBAAe,aAAa,CAAA;AAEf,QAAA,aAAa,GAAG,IAAA,2BAAkB,EAAC,aAAa,CAAC,CAAA"}
|
|
@@ -44,12 +44,11 @@ function addDependencies(tree) {
|
|
|
44
44
|
// but add them if not. They are added with the same version that the host workspace is using.
|
|
45
45
|
// This is cleaner than using peerDeps.
|
|
46
46
|
addDevDependencyIfNotPresent('@nx/devkit', utils_1.workspaceNxVersion.version);
|
|
47
|
-
// used by the plugin
|
|
47
|
+
// used by the plugin function generator as a proxy for creating a typescript app
|
|
48
|
+
addDevDependencyIfNotPresent('@nx/node', utils_1.workspaceNxVersion.version);
|
|
48
49
|
addDevDependencyIfNotPresent('@nx/linter', utils_1.workspaceNxVersion.version);
|
|
49
50
|
addDevDependencyIfNotPresent('@nx/jest', utils_1.workspaceNxVersion.version);
|
|
50
|
-
|
|
51
|
-
addDevDependencyIfNotPresent('@nx/node', utils_1.workspaceNxVersion.version);
|
|
52
|
-
// used by the plugin application builder
|
|
51
|
+
addDevDependencyIfNotPresent('@nx/esbuild', utils_1.workspaceNxVersion.version);
|
|
53
52
|
addDevDependencyIfNotPresent('@nx/js', utils_1.workspaceNxVersion.version);
|
|
54
53
|
return (0, devkit_2.addDependenciesToPackageJson)(tree, dependencies, devDependencies);
|
|
55
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-dependencies.js","sourceRoot":"","sources":["../../../../../../../packages/nx-firebase/src/generators/init/lib/add-dependencies.ts"],"names":[],"mappings":";;;AAAA,uCAA8D;AAC9D,uCAAyD;AACzD,0CAAmD;AACnD,sDAQgC;AAEhC,SAAgB,eAAe,CAAC,IAAU;IACxC,MAAM,YAAY,GAA2B,EAAE,CAAA;IAC/C,MAAM,eAAe,GAA2B,EAAE,CAAA;IAElD,0EAA0E;IAC1E,8EAA8E;IAC9E,gGAAgG;IAChG,2EAA2E;IAC3E,MAAM,WAAW,GAAG,IAAA,iBAAQ,EAAC,IAAI,EAAE,cAAc,CAAC,CAAA,CAAC,uBAAuB;IAE1E,SAAS,yBAAyB,CAChC,WAAmB,EACnB,cAAsB;QAEtB,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE;YAC1C,YAAY,CAAC,WAAW,CAAC,GAAG,cAAc,CAAA;SAC3C;IACH,CAAC;IACD,SAAS,4BAA4B,CACnC,WAAmB,EACnB,cAAsB;QAEtB,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,WAAW,CAAC,EAAE;YAC7C,eAAe,CAAC,WAAW,CAAC,GAAG,cAAc,CAAA;SAC9C;IACH,CAAC;IAED,wBAAwB;IACxB,yBAAyB,CAAC,UAAU,EAAE,0BAAe,CAAC,CAAA;IACtD,yBAAyB,CAAC,gBAAgB,EAAE,+BAAoB,CAAC,CAAA;IACjE,yBAAyB,CAAC,oBAAoB,EAAE,mCAAwB,CAAC,CAAA;IAEzE,4DAA4D;IAC5D,kDAAkD;IAElD,4BAA4B;IAC5B,4BAA4B,CAAC,gBAAgB,EAAE,+BAAoB,CAAC,CAAA;IACpE,4BAA4B,CAC1B,yBAAyB,EACzB,uCAA4B,CAC7B,CAAA;IAED,2EAA2E;IAC3E,8CAA8C;IAC9C,4BAA4B,CAAC,WAAW,EAAE,0BAAe,CAAC,CAAA;IAE1D,6EAA6E;IAC7E,2GAA2G;IAC3G,QAAQ;IACR,yHAAyH;IACzH,EAAE;IAEF,qGAAqG;IACrG,8FAA8F;IAC9F,uCAAuC;IACvC,4BAA4B,CAAC,YAAY,EAAE,0BAAkB,CAAC,OAAO,CAAC,CAAA;IAEtE,
|
|
1
|
+
{"version":3,"file":"add-dependencies.js","sourceRoot":"","sources":["../../../../../../../packages/nx-firebase/src/generators/init/lib/add-dependencies.ts"],"names":[],"mappings":";;;AAAA,uCAA8D;AAC9D,uCAAyD;AACzD,0CAAmD;AACnD,sDAQgC;AAEhC,SAAgB,eAAe,CAAC,IAAU;IACxC,MAAM,YAAY,GAA2B,EAAE,CAAA;IAC/C,MAAM,eAAe,GAA2B,EAAE,CAAA;IAElD,0EAA0E;IAC1E,8EAA8E;IAC9E,gGAAgG;IAChG,2EAA2E;IAC3E,MAAM,WAAW,GAAG,IAAA,iBAAQ,EAAC,IAAI,EAAE,cAAc,CAAC,CAAA,CAAC,uBAAuB;IAE1E,SAAS,yBAAyB,C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AE,0BAAkB,CAAC,OAAO,CAAC,CAAA;IAElE,OAAO,IAAA,qCAA4B,EAAC,IAAI,EAAE,YAAY,EAAE,eAAe,CAAC,CAAA;AAC1E,CAAC;AAjED,0CAiEC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
|
-
export declare const gitIgnoreEntries = "\n\n# Nx-Firebase\n.runtimeconfig.json\n**/.emulators/*\n**/.firebase/*\ndatabase-debug.log\nfirebase-debug.log\nfirestore-debug.log\npubsub-debug.log\nui-debug.log\n\n";
|
|
2
|
+
export declare const gitIgnoreEntries = "\n\n# Nx-Firebase\n.runtimeconfig.json\n**/.emulators/*\n**/.firebase/*\ndatabase-debug.log\nfirebase-debug.log\nfirestore-debug.log\npubsub-debug.log\nui-debug.log\nfirebase-export*\n\n";
|
|
3
3
|
export declare function addGitIgnoreEntry(host: Tree): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-git-ignore-entry.js","sourceRoot":"","sources":["../../../../../../../packages/nx-firebase/src/generators/init/lib/add-git-ignore-entry.ts"],"names":[],"mappings":";;;AAEa,QAAA,gBAAgB,GAAG
|
|
1
|
+
{"version":3,"file":"add-git-ignore-entry.js","sourceRoot":"","sources":["../../../../../../../packages/nx-firebase/src/generators/init/lib/add-git-ignore-entry.ts"],"names":[],"mappings":";;;AAEa,QAAA,gBAAgB,GAAG;;;;;;;;;;;;;CAa/B,CAAA;AAED,SAAgB,iBAAiB,CAAC,IAAU;;IAC1C,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE;QAC9B,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,wBAAgB,CAAC,CAAA;QAC1C,OAAM;KACP;IAED,MAAM,OAAO,GAAG,MAAA,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,0CAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;IAC1D,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,wBAAgB,CAAC,EAAE;QACvC,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,OAAO,CAAC,MAAM,CAAC,wBAAgB,CAAC,CAAC,CAAA;KAC3D;AACH,CAAC;AAVD,8CAUC"}
|
|
@@ -8,18 +8,19 @@
|
|
|
8
8
|
"unitTestRunner": {
|
|
9
9
|
"description": "Adds the specified unit test runner.",
|
|
10
10
|
"type": "string",
|
|
11
|
-
"enum": [
|
|
12
|
-
|
|
13
|
-
"none"
|
|
14
|
-
],
|
|
15
|
-
"default": "none"
|
|
11
|
+
"enum": ["jest", "none"],
|
|
12
|
+
"default": "jest"
|
|
16
13
|
},
|
|
17
14
|
"skipFormat": {
|
|
18
15
|
"description": "Skip formatting files.",
|
|
19
16
|
"type": "boolean",
|
|
20
|
-
"default":
|
|
17
|
+
"default": false
|
|
18
|
+
},
|
|
19
|
+
"js": {
|
|
20
|
+
"type": "boolean",
|
|
21
|
+
"default": false,
|
|
22
|
+
"description": "Use JavaScript instead of TypeScript"
|
|
21
23
|
}
|
|
22
24
|
},
|
|
23
|
-
"additionalProperties": false,
|
|
24
25
|
"required": []
|
|
25
26
|
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFirebaseChanges = void 0;
|
|
4
|
+
const debug_1 = require("../../../utils/debug");
|
|
5
|
+
const tags_1 = require("./tags");
|
|
6
|
+
/**
|
|
7
|
+
* Check if the given firebase project has been renamed by checking its `firebase:name` tag
|
|
8
|
+
* @param project - Firebase project to be checked
|
|
9
|
+
* @returns the previous project name if renamed, otherwise undefined/falsy
|
|
10
|
+
*/
|
|
11
|
+
function isRenamed(project) {
|
|
12
|
+
const { tagValue } = (0, tags_1.getFirebaseScopeFromTag)(project, 'firebase:name');
|
|
13
|
+
(0, debug_1.debugInfo)(`- checking if project ${project.name} is renamed, will be different to ${tagValue}`);
|
|
14
|
+
if (tagValue !== project.name) {
|
|
15
|
+
(0, debug_1.debugInfo)(`- firebase project ${tagValue} has been renamed to ${project.name} `);
|
|
16
|
+
return tagValue;
|
|
17
|
+
}
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
function getFirebaseChanges(tree, projects, configs) {
|
|
21
|
+
// map of project name -> deletion status
|
|
22
|
+
const deletedApps = new Map();
|
|
23
|
+
const deletedFunctions = new Map();
|
|
24
|
+
// map of previous name -> new name
|
|
25
|
+
const renamedApps = new Map();
|
|
26
|
+
const renamedFunctions = new Map();
|
|
27
|
+
// 1. determine renamed apps using the firebase:name tag
|
|
28
|
+
function checkRenamedProject(project, renamedCollection) {
|
|
29
|
+
const renamedProject = isRenamed(project);
|
|
30
|
+
if (renamedProject) {
|
|
31
|
+
(0, debug_1.debugInfo)(`- ${renamedProject} has been renamed to ${project.name} `);
|
|
32
|
+
renamedCollection.set(renamedProject, project);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
(0, debug_1.debugInfo)(`- checking for renamed apps & functions`);
|
|
36
|
+
projects.firebaseAppProjects.forEach((project) => checkRenamedProject(project, renamedApps));
|
|
37
|
+
projects.firebaseFunctionProjects.forEach((project) => checkRenamedProject(project, renamedFunctions));
|
|
38
|
+
// 2. determine deleted functions
|
|
39
|
+
// do this either by detecting a dependency
|
|
40
|
+
(0, debug_1.debugInfo)(`- checking apps for deleted function deps`);
|
|
41
|
+
projects.firebaseAppProjects.forEach((firebaseAppProject, firebaseAppProjectName) => {
|
|
42
|
+
var _a;
|
|
43
|
+
// check the implicitDependencies for each app first
|
|
44
|
+
(_a = firebaseAppProject.implicitDependencies) === null || _a === void 0 ? void 0 : _a.map((dep) => {
|
|
45
|
+
if (!projects.firebaseFunctionProjects.has(dep) &&
|
|
46
|
+
!renamedFunctions.has(dep)) {
|
|
47
|
+
(0, debug_1.debugInfo)(`- function ${dep} is a dep, but cannot be located so function is deleted`);
|
|
48
|
+
deletedFunctions.set(dep, true);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
// functions may also be removed using nx g rm <function> --forceRemove
|
|
52
|
+
// which removes the implicitDep from the app, but doesnt update the firebase config
|
|
53
|
+
// so we need to check the firebase config too, and determine any projects that are in there
|
|
54
|
+
// but not in the workspace and mark them as deleted
|
|
55
|
+
const firebaseConfigName = configs.firebaseAppConfigs.get(firebaseAppProjectName);
|
|
56
|
+
(0, debug_1.debugInfo)(`- checking config ${firebaseConfigName} to see if it contains a function that doesnt exist`);
|
|
57
|
+
const config = configs.firebaseConfigs.get(firebaseConfigName);
|
|
58
|
+
if (!config) {
|
|
59
|
+
throw new Error(`Could not get firebase config '${firebaseConfigName}'`);
|
|
60
|
+
}
|
|
61
|
+
// ensure config functions is always an array, even if only 1 function
|
|
62
|
+
// just in case user has modified this.
|
|
63
|
+
if (!Array.isArray(config.functions)) {
|
|
64
|
+
config.functions = [config.functions];
|
|
65
|
+
}
|
|
66
|
+
// remove deleted functions
|
|
67
|
+
config.functions.forEach((func) => {
|
|
68
|
+
const funcName = func.codebase;
|
|
69
|
+
if (!projects.firebaseFunctionProjects.has(funcName) &&
|
|
70
|
+
!renamedFunctions.has(funcName)) {
|
|
71
|
+
(0, debug_1.debugInfo)(`- function ${funcName} is in config ${firebaseConfigName}, but cannot be located so function must be deleted`);
|
|
72
|
+
deletedFunctions.set(funcName, true);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
// nx g mv --project=source --destination=dstname
|
|
77
|
+
// DOES update implicitDeps
|
|
78
|
+
// Again, this means implicitDep wont be wrong, but we cant use it to detect renames
|
|
79
|
+
// This is ok though because we detect renamed functions via tags
|
|
80
|
+
// determine deleted apps
|
|
81
|
+
(0, debug_1.debugInfo)(`- checking functions for deleted apps`);
|
|
82
|
+
projects.firebaseFunctionProjects.forEach((firebaseFunctionProject, firebaseFunctionName) => {
|
|
83
|
+
const { tagValue } = (0, tags_1.getFirebaseScopeFromTag)(firebaseFunctionProject, 'firebase:dep');
|
|
84
|
+
if (!projects.firebaseAppProjects.has(tagValue) &&
|
|
85
|
+
!renamedApps.has(tagValue)) {
|
|
86
|
+
(0, debug_1.debugInfo)(`- function ${firebaseFunctionName} points to app ${tagValue} which doesnt exist, so app must be deleted`);
|
|
87
|
+
deletedApps.set(tagValue, true);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
(0, debug_1.debugInfo)(`- deletedApps=${(0, debug_1.mapKeys)(deletedApps)}`);
|
|
91
|
+
(0, debug_1.debugInfo)(`- deletedFunctions=${(0, debug_1.mapKeys)(deletedFunctions)}`);
|
|
92
|
+
(0, debug_1.debugInfo)(`- renamedApps=${(0, debug_1.mapKeys)(renamedApps)}`);
|
|
93
|
+
(0, debug_1.debugInfo)(`- renamedFunctions=${(0, debug_1.mapKeys)(renamedFunctions)}`);
|
|
94
|
+
return {
|
|
95
|
+
deletedApps,
|
|
96
|
+
deletedFunctions,
|
|
97
|
+
renamedApps,
|
|
98
|
+
renamedFunctions,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
exports.getFirebaseChanges = getFirebaseChanges;
|
|
102
|
+
//# sourceMappingURL=firebase-changes.js.map
|