@simondotm/nx-firebase 2.1.1 → 2.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simondotm/nx-firebase",
3
- "version": "2.1.1",
3
+ "version": "2.2.0",
4
4
  "description": "A Firebase plugin for Nx monorepo workspaces.",
5
5
  "author": "Simon Morris",
6
6
  "license": "MIT",
@@ -21,11 +21,10 @@
21
21
  "generators": "./generators.json",
22
22
  "executors": "./executors.json",
23
23
  "peerDependencies": {
24
+ "@nx/devkit": ">= 16.1.1",
24
25
  "@nx/workspace": ">= 16.1.1",
25
26
  "nx": ">= 16.1.1"
26
27
  },
27
- "dependencies": {
28
- "@nx/node": "^16.1.1"
29
- },
28
+ "dependencies": {},
30
29
  "types": "./src/index.d.ts"
31
30
  }
@@ -5,7 +5,7 @@
5
5
  "test": "nx test <%= projectName %>",
6
6
  "lint": "nx lint <%= projectName %>",
7
7
  "build": "nx build <%= projectName %>",
8
- "deploy": "nx deploy <%= projectName %>",
8
+ "deploy": "nx deploy <%= projectName %>"
9
9
  },
10
10
  "type": "<%= moduleType %>",
11
11
  "engines": {
@@ -1,15 +1,11 @@
1
1
  import type { GeneratorCallback, Tree } from '@nx/devkit';
2
2
  import type { InitGeneratorOptions } from './schema';
3
3
  /**
4
- * `nx g @simondotm/nx-firebase:init` is based on the `@nx/nest` plugin
5
- * which in turn is based on the `@nx/node` plugin
4
+ * `nx g @simondotm/nx-firebase:init`
6
5
  *
7
6
  * Ensures the necessary firebase packages are installed in the nx workspace
8
- * The `@nx/node` init generate also ensures jest configs
7
+ * It also adds `@nx/node` if it is not already installed
9
8
  *
10
- * Docs say its for internal use only, but nest uses it, so we use it :)
11
- * https://nx.dev/packages/node/generators/init
12
9
  */
13
- export declare function initGenerator(tree: Tree, rawOptions: InitGeneratorOptions): Promise<GeneratorCallback>;
10
+ export declare function initGenerator(tree: Tree, options: InitGeneratorOptions): Promise<GeneratorCallback>;
14
11
  export default initGenerator;
15
- export declare const initSchematic: (generatorOptions: InitGeneratorOptions) => (tree: any, context: any) => Promise<any>;
@@ -1,32 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.initSchematic = exports.initGenerator = void 0;
3
+ exports.initGenerator = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const devkit_1 = require("@nx/devkit");
6
- const node_1 = require("@nx/node");
7
5
  const lib_1 = require("./lib");
8
6
  const add_git_ignore_entry_1 = require("./lib/add-git-ignore-entry");
9
7
  /**
10
- * `nx g @simondotm/nx-firebase:init` is based on the `@nx/nest` plugin
11
- * which in turn is based on the `@nx/node` plugin
8
+ * `nx g @simondotm/nx-firebase:init`
12
9
  *
13
10
  * Ensures the necessary firebase packages are installed in the nx workspace
14
- * The `@nx/node` init generate also ensures jest configs
11
+ * It also adds `@nx/node` if it is not already installed
15
12
  *
16
- * Docs say its for internal use only, but nest uses it, so we use it :)
17
- * https://nx.dev/packages/node/generators/init
18
13
  */
19
- function initGenerator(tree, rawOptions) {
14
+ function initGenerator(tree, options) {
20
15
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
21
- const options = (0, lib_1.normalizeOptions)(rawOptions);
22
- const nodeInitTask = yield (0, node_1.initGenerator)(tree, options);
23
- const installPackagesTask = (0, lib_1.addDependencies)(tree);
24
16
  (0, add_git_ignore_entry_1.addGitIgnore)(tree);
25
17
  (0, add_git_ignore_entry_1.addNxIgnore)(tree);
26
- return (0, devkit_1.runTasksInSerial)(nodeInitTask, installPackagesTask);
18
+ return (0, lib_1.addDependencies)(tree);
27
19
  });
28
20
  }
29
21
  exports.initGenerator = initGenerator;
30
22
  exports.default = initGenerator;
31
- exports.initSchematic = (0, devkit_1.convertNxGenerator)(initGenerator);
32
23
  //# sourceMappingURL=init.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"init.js","sourceRoot":"","sources":["../../../../../../packages/nx-firebase/src/generators/init/init.ts"],"names":[],"mappings":";;;;AACA,uCAAiE;AACjE,mCAA6D;AAC7D,+BAAyD;AACzD,qEAAsE;AAGtE;;;;;;;;;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,mCAAY,EAAC,IAAI,CAAC,CAAA;QAClB,IAAA,kCAAW,EAAC,IAAI,CAAC,CAAA;QAEjB,OAAO,IAAA,yBAAgB,EAAC,YAAY,EAAE,mBAAmB,CAAC,CAAA;IAC5D,CAAC;CAAA;AAXD,sCAWC;AAED,kBAAe,aAAa,CAAA;AAEf,QAAA,aAAa,GAAG,IAAA,2BAAkB,EAAC,aAAa,CAAC,CAAA"}
1
+ {"version":3,"file":"init.js","sourceRoot":"","sources":["../../../../../../packages/nx-firebase/src/generators/init/init.ts"],"names":[],"mappings":";;;;AACA,+BAAuC;AACvC,qEAAsE;AAGtE;;;;;;GAMG;AACH,SAAsB,aAAa,CACjC,IAAU,EACV,OAA6B;;QAE7B,IAAA,mCAAY,EAAC,IAAI,CAAC,CAAA;QAClB,IAAA,kCAAW,EAAC,IAAI,CAAC,CAAA;QACjB,OAAO,IAAA,qBAAe,EAAC,IAAI,CAAC,CAAA;IAC9B,CAAC;CAAA;AAPD,sCAOC;AAED,kBAAe,aAAa,CAAA"}
@@ -11,14 +11,15 @@ function addDependencies(tree) {
11
11
  // This is atypical for Nx plugins that usually migrate versions automatically
12
12
  // however the nx-firebase plugin is not (currently) opinionated about which version is needed,
13
13
  // so this ensures workspaces retain control over their firebase versions.
14
- const packageJson = (0, devkit_1.readJson)(tree, 'package.json'); //readRootPackageJson()
14
+ const packageJson = (0, devkit_1.readJson)(tree, 'package.json');
15
15
  function addDependencyIfNotPresent(packageName, packageVersion) {
16
- if (!packageJson.dependencies[packageName]) {
16
+ if (!packageJson.dependencies || !packageJson.dependencies[packageName]) {
17
17
  dependencies[packageName] = packageVersion;
18
18
  }
19
19
  }
20
20
  function addDevDependencyIfNotPresent(packageName, packageVersion) {
21
- if (!packageJson.devDependencies[packageName]) {
21
+ if (!packageJson.devDependencies ||
22
+ !packageJson.devDependencies[packageName]) {
22
23
  devDependencies[packageName] = packageVersion;
23
24
  }
24
25
  }
@@ -34,21 +35,11 @@ function addDependencies(tree) {
34
35
  // kill-port is used by the emulate target to ensure clean emulator startup
35
36
  // since Nx doesn't kill processes cleanly atm
36
37
  addDevDependencyIfNotPresent('kill-port', versions_1.killportVersion);
37
- // TODO: find out if Nx devkit adds these versions even if they already exist
38
- // for now, only add them if they aren't in the workspace already at the same version as the host workspace
39
- // from:
40
- // https://github.com/nrwl/nx/blob/5b7dba1cb78cabcf631129b4ce8163406b9c1328/packages/devkit/src/utils/package-json.ts#L84
41
- //
42
- // These dependencies are required by the plugin internals, most likely already in the host workspace
43
- // but add them if not. They are added with the same version that the host workspace is using.
44
- // This is cleaner than using peerDeps.
45
- addDevDependencyIfNotPresent('@nx/devkit', utils_1.workspaceNxVersion.version);
46
- // used by the plugin function generator as a proxy for creating a typescript app
38
+ // @nx/node is used by the plugin function generator as a proxy for creating a typescript app
39
+ // since users have to create a firebase app before they generate a function, we can be sure
40
+ // this plugin init will have been run before the function generator that requires @nx/node is used
41
+ // we defer to @nx/node to install its own plugins such as @nx/eslint, @nx/jest, @nx/js, @nx/esbuild, @nx/webpack etc.
47
42
  addDevDependencyIfNotPresent('@nx/node', utils_1.workspaceNxVersion.version);
48
- addDevDependencyIfNotPresent('@nx/linter', utils_1.workspaceNxVersion.version);
49
- addDevDependencyIfNotPresent('@nx/jest', utils_1.workspaceNxVersion.version);
50
- addDevDependencyIfNotPresent('@nx/esbuild', utils_1.workspaceNxVersion.version);
51
- addDevDependencyIfNotPresent('@nx/js', utils_1.workspaceNxVersion.version);
52
43
  return (0, devkit_1.addDependenciesToPackageJson)(tree, dependencies, devDependencies);
53
44
  }
54
45
  exports.addDependencies = addDependencies;
@@ -1 +1 @@
1
- {"version":3,"file":"add-dependencies.js","sourceRoot":"","sources":["../../../../../../../packages/nx-firebase/src/generators/init/lib/add-dependencies.ts"],"names":[],"mappings":";;;AAAA,uCAKmB;AACnB,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,iFAAiF;IACjF,4BAA4B,CAAC,UAAU,EAAE,0BAAkB,CAAC,OAAO,CAAC,CAAA;IACpE,4BAA4B,CAAC,YAAY,EAAE,0BAAkB,CAAC,OAAO,CAAC,CAAA;IACtE,4BAA4B,CAAC,UAAU,EAAE,0BAAkB,CAAC,OAAO,CAAC,CAAA;IACpE,4BAA4B,CAAC,aAAa,EAAE,0BAAkB,CAAC,OAAO,CAAC,CAAA;IACvE,4BAA4B,CAAC,QAAQ,EAAE,0BAAkB,CAAC,OAAO,CAAC,CAAA;IAElE,OAAO,IAAA,qCAA4B,EAAC,IAAI,EAAE,YAAY,EAAE,eAAe,CAAC,CAAA;AAC1E,CAAC;AAjED,0CAiEC"}
1
+ {"version":3,"file":"add-dependencies.js","sourceRoot":"","sources":["../../../../../../../packages/nx-firebase/src/generators/init/lib/add-dependencies.ts"],"names":[],"mappings":";;;AAAA,uCAKmB;AACnB,0CAAmD;AACnD,sDAOgC;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;IAElD,SAAS,yBAAyB,CAChC,WAAmB,EACnB,cAAsB;QAEtB,IAAI,CAAC,WAAW,CAAC,YAAY,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE;YACvE,YAAY,CAAC,WAAW,CAAC,GAAG,cAAc,CAAA;SAC3C;IACH,CAAC;IACD,SAAS,4BAA4B,CACnC,WAAmB,EACnB,cAAsB;QAEtB,IACE,CAAC,WAAW,CAAC,eAAe;YAC5B,CAAC,WAAW,CAAC,eAAe,CAAC,WAAW,CAAC,EACzC;YACA,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,6FAA6F;IAC7F,4FAA4F;IAC5F,mGAAmG;IACnG,sHAAsH;IACtH,4BAA4B,CAAC,UAAU,EAAE,0BAAkB,CAAC,OAAO,CAAC,CAAA;IACpE,OAAO,IAAA,qCAA4B,EAAC,IAAI,EAAE,YAAY,EAAE,eAAe,CAAC,CAAA;AAC1E,CAAC;AAvDD,0CAuDC"}
@@ -1,3 +1,2 @@
1
1
  export * from './add-dependencies';
2
- export * from './normalize-options';
3
2
  export * from './add-git-ignore-entry';
@@ -2,6 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./add-dependencies"), exports);
5
- tslib_1.__exportStar(require("./normalize-options"), exports);
6
5
  tslib_1.__exportStar(require("./add-git-ignore-entry"), exports);
7
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/nx-firebase/src/generators/init/lib/index.ts"],"names":[],"mappings":";;;AAAA,6DAAkC;AAClC,8DAAmC;AACnC,iEAAsC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/nx-firebase/src/generators/init/lib/index.ts"],"names":[],"mappings":";;;AAAA,6DAAkC;AAClC,iEAAsC"}
@@ -1,6 +1 @@
1
- export interface InitGeneratorOptions {
2
- unitTestRunner?: 'jest' | 'none'
3
- skipFormat?: boolean
4
- js?: boolean
5
- rootProject?: boolean
6
- }
1
+ export type InitGeneratorOptions = unknown
@@ -4,23 +4,6 @@
4
4
  "title": "Init Firebase Plugin",
5
5
  "description": "Init Firebase Plugin.",
6
6
  "type": "object",
7
- "properties": {
8
- "unitTestRunner": {
9
- "description": "Adds the specified unit test runner.",
10
- "type": "string",
11
- "enum": ["jest", "none"],
12
- "default": "jest"
13
- },
14
- "skipFormat": {
15
- "description": "Skip formatting files.",
16
- "type": "boolean",
17
- "default": false
18
- },
19
- "js": {
20
- "type": "boolean",
21
- "default": false,
22
- "description": "Use JavaScript instead of TypeScript"
23
- }
24
- },
7
+ "properties": {},
25
8
  "required": []
26
9
  }
@@ -1,2 +0,0 @@
1
- import type { InitGeneratorOptions } from '../schema';
2
- export declare function normalizeOptions(options: InitGeneratorOptions): InitGeneratorOptions;
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeOptions = void 0;
4
- function normalizeOptions(options) {
5
- var _a;
6
- return Object.assign(Object.assign({}, options), { unitTestRunner: (_a = options.unitTestRunner) !== null && _a !== void 0 ? _a : 'jest' });
7
- }
8
- exports.normalizeOptions = normalizeOptions;
9
- //# sourceMappingURL=normalize-options.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"normalize-options.js","sourceRoot":"","sources":["../../../../../../../packages/nx-firebase/src/generators/init/lib/normalize-options.ts"],"names":[],"mappings":";;;AAEA,SAAgB,gBAAgB,CAC9B,OAA6B;;IAE7B,uCACK,OAAO,KACV,cAAc,EAAE,MAAA,OAAO,CAAC,cAAc,mCAAI,MAAM,IACjD;AACH,CAAC;AAPD,4CAOC"}