@ronas-it/nx-generators 0.1.4 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -2
- package/generators.json +10 -0
- package/package.json +1 -1
- package/src/generators/expo-app/files/metro.config.js.template +34 -0
- package/src/generators/expo-app/generator.js +1 -0
- package/src/generators/expo-app/generator.js.map +1 -1
- package/src/generators/expo-app/schema.d.ts +1 -1
- package/src/generators/react-component/files/component.tsx.template +10 -0
- package/src/generators/react-component/files/index.ts.template +1 -0
- package/src/generators/react-component/generator.d.ts +4 -0
- package/src/generators/react-component/generator.js +31 -0
- package/src/generators/react-component/generator.js.map +1 -0
- package/src/generators/react-component/schema.d.ts +6 -0
- package/src/generators/react-component/schema.json +23 -0
- package/src/generators/react-lib/files/lib/component.tsx.template +10 -0
- package/src/generators/react-lib/generator.d.ts +4 -0
- package/src/generators/react-lib/generator.js +33 -0
- package/src/generators/react-lib/generator.js.map +1 -0
- package/src/generators/react-lib/schema.d.ts +10 -0
- package/src/generators/react-lib/schema.json +47 -0
- package/src/shared/utils/cli-utils.d.ts +8 -0
- package/src/shared/utils/cli-utils.js +32 -0
- package/src/shared/utils/cli-utils.js.map +1 -0
- package/src/shared/utils/format-utils.d.ts +3 -0
- package/src/shared/{utils.js → utils/format-utils.js} +6 -4
- package/src/shared/utils/format-utils.js.map +1 -0
- package/src/shared/utils/index.d.ts +2 -0
- package/src/shared/utils/index.js +6 -0
- package/src/shared/utils/index.js.map +1 -0
- package/src/shared/utils.d.ts +0 -2
- package/src/shared/utils.js.map +0 -1
package/README.md
CHANGED
|
@@ -5,8 +5,10 @@ NX generators for Ronas IT projects.
|
|
|
5
5
|
At the moment this library contains the following generators:
|
|
6
6
|
|
|
7
7
|
1. `repo-config` - setups the monorepo structure for React Native development.
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
1. `code-checks` - configures code checks and formatting with pre-commit hook.
|
|
9
|
+
1. `expo-app` - generates and configures Expo React Native app.
|
|
10
|
+
1. `react-lib` - generates a library according to [NX notation](https://nx.dev/concepts/more-concepts/applications-and-libraries).
|
|
11
|
+
1. `react-component` - creates a React component in particular library.
|
|
10
12
|
|
|
11
13
|
## Usage
|
|
12
14
|
|
|
@@ -41,3 +43,16 @@ npx nx g repo-config && npx nx g code-checks && npx nx g expo-app
|
|
|
41
43
|
```sh
|
|
42
44
|
npx nx start my-app
|
|
43
45
|
```
|
|
46
|
+
|
|
47
|
+
5. Continue developing your app by generating libraries and components:
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
npx nx g react-lib mobile/account/features/profile-settings --withComponent
|
|
51
|
+
npx nx g react-component
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Each generator accepts the `--help` argument to see generator instructions.
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
npx nx g react-lib --help
|
|
58
|
+
```
|
package/generators.json
CHANGED
|
@@ -14,6 +14,16 @@
|
|
|
14
14
|
"factory": "./src/generators/repo-config/generator",
|
|
15
15
|
"schema": "./src/generators/repo-config/schema.json",
|
|
16
16
|
"description": "repo-config generator"
|
|
17
|
+
},
|
|
18
|
+
"react-lib": {
|
|
19
|
+
"factory": "./src/generators/react-lib/generator",
|
|
20
|
+
"schema": "./src/generators/react-lib/schema.json",
|
|
21
|
+
"description": "react-lib generator"
|
|
22
|
+
},
|
|
23
|
+
"react-component": {
|
|
24
|
+
"factory": "./src/generators/react-component/generator",
|
|
25
|
+
"schema": "./src/generators/react-component/schema.json",
|
|
26
|
+
"description": "react-component generator"
|
|
17
27
|
}
|
|
18
28
|
}
|
|
19
29
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const { getDefaultConfig } = require('@expo/metro-config');
|
|
2
|
+
const { withNxMetro } = require('@nx/expo');
|
|
3
|
+
const { mergeConfig } = require('metro-config');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
const appRoot = __dirname;
|
|
7
|
+
const monorepoRoot = path.resolve(appRoot, '../..');
|
|
8
|
+
const defaultConfig = getDefaultConfig(appRoot);
|
|
9
|
+
const { assetExts, sourceExts } = defaultConfig.resolver;
|
|
10
|
+
/**
|
|
11
|
+
* Metro configuration
|
|
12
|
+
* https://facebook.github.io/metro/docs/configuration
|
|
13
|
+
*
|
|
14
|
+
* @type {import('metro-config').MetroConfig}
|
|
15
|
+
*/
|
|
16
|
+
const customConfig = {
|
|
17
|
+
transformer: {
|
|
18
|
+
babelTransformerPath: require.resolve('react-native-svg-transformer'),
|
|
19
|
+
},
|
|
20
|
+
resolver: {
|
|
21
|
+
assetExts: assetExts.filter((ext) => ext !== 'svg'),
|
|
22
|
+
sourceExts: [...sourceExts, 'cjs', 'mjs', 'svg'],
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
module.exports = withNxMetro(mergeConfig(defaultConfig, customConfig), {
|
|
27
|
+
// Change this to true to see debugging info.
|
|
28
|
+
// Useful if you have issues resolving modules
|
|
29
|
+
debug: false,
|
|
30
|
+
// all the file extensions used for imports other than 'ts', 'tsx', 'js', 'jsx', 'json'
|
|
31
|
+
extensions: [],
|
|
32
|
+
// Specify folders to watch, in addition to Nx defaults (workspace libraries and node_modules)
|
|
33
|
+
watchFolders: [monorepoRoot],
|
|
34
|
+
});
|
|
@@ -31,6 +31,7 @@ function expoAppGenerator(tree, options) {
|
|
|
31
31
|
tree.delete(`${appRoot}/.eslintrc.json`);
|
|
32
32
|
tree.delete(`${appRoot}/app.json`);
|
|
33
33
|
tree.delete(`${appRoot}/eas.json`);
|
|
34
|
+
tree.delete(`${appRoot}/metro.config.js`);
|
|
34
35
|
// Update app package.json
|
|
35
36
|
const appPackageJson = (0, devkit_1.readJson)(tree, appPackagePath);
|
|
36
37
|
appPackageJson.main = 'expo-router/entry';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../plugin/src/generators/expo-app/generator.ts"],"names":[],"mappings":";;;;AAAA,iDAAyC;AACzC,6BAA6B;AAC7B,uCAQoB;AAEpB,uCAAgC;AAChC,2BAAgC;AAChC,8CAAgD;AAEhD,MAAM,YAAY,GAAG;IACnB,gBAAgB,EAAE,SAAS;IAC3B,aAAa,EAAE,QAAQ;IACvB,gCAAgC,EAAE,QAAQ;IAC1C,sBAAsB,EAAE,SAAS;IACjC,cAAc,EAAE,QAAQ;IACxB,iBAAiB,EAAE,SAAS;IAC5B,cAAc,EAAE,UAAU;CAC3B,CAAC;AAEF,SAAsB,gBAAgB,CACpC,IAAU,EACV,OAA+B;;QAE/B,MAAM,OAAO,GAAG,QAAQ,OAAO,CAAC,SAAS,EAAE,CAAC;QAE5C,IAAI,CAAC,IAAA,eAAU,EAAC,OAAO,CAAC,EAAE,CAAC;YACzB,IAAA,wBAAQ,EACN,gBAAgB,OAAO,CAAC,IAAI,qBAAqB,OAAO,CAAC,SAAS,oFAAoF,CACvJ,CAAC;QACJ,CAAC;QAED,MAAM,cAAc,GAAG,GAAG,OAAO,eAAe,CAAC;QAEjD,2DAA2D;QAC3D,IAAI,CAAC,MAAM,CAAC,GAAG,OAAO,MAAM,CAAC,CAAC;QAC9B,IAAI,CAAC,MAAM,CAAC,GAAG,OAAO,WAAW,CAAC,CAAC;QACnC,IAAI,CAAC,MAAM,CAAC,GAAG,OAAO,oBAAoB,CAAC,CAAC;QAC5C,IAAI,CAAC,MAAM,CAAC,GAAG,OAAO,iBAAiB,CAAC,CAAC;QACzC,IAAI,CAAC,MAAM,CAAC,GAAG,OAAO,WAAW,CAAC,CAAC;QACnC,IAAI,CAAC,MAAM,CAAC,GAAG,OAAO,WAAW,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../plugin/src/generators/expo-app/generator.ts"],"names":[],"mappings":";;;;AAAA,iDAAyC;AACzC,6BAA6B;AAC7B,uCAQoB;AAEpB,uCAAgC;AAChC,2BAAgC;AAChC,8CAAgD;AAEhD,MAAM,YAAY,GAAG;IACnB,gBAAgB,EAAE,SAAS;IAC3B,aAAa,EAAE,QAAQ;IACvB,gCAAgC,EAAE,QAAQ;IAC1C,sBAAsB,EAAE,SAAS;IACjC,cAAc,EAAE,QAAQ;IACxB,iBAAiB,EAAE,SAAS;IAC5B,cAAc,EAAE,UAAU;CAC3B,CAAC;AAEF,SAAsB,gBAAgB,CACpC,IAAU,EACV,OAA+B;;QAE/B,MAAM,OAAO,GAAG,QAAQ,OAAO,CAAC,SAAS,EAAE,CAAC;QAE5C,IAAI,CAAC,IAAA,eAAU,EAAC,OAAO,CAAC,EAAE,CAAC;YACzB,IAAA,wBAAQ,EACN,gBAAgB,OAAO,CAAC,IAAI,qBAAqB,OAAO,CAAC,SAAS,oFAAoF,CACvJ,CAAC;QACJ,CAAC;QAED,MAAM,cAAc,GAAG,GAAG,OAAO,eAAe,CAAC;QAEjD,2DAA2D;QAC3D,IAAI,CAAC,MAAM,CAAC,GAAG,OAAO,MAAM,CAAC,CAAC;QAC9B,IAAI,CAAC,MAAM,CAAC,GAAG,OAAO,WAAW,CAAC,CAAC;QACnC,IAAI,CAAC,MAAM,CAAC,GAAG,OAAO,oBAAoB,CAAC,CAAC;QAC5C,IAAI,CAAC,MAAM,CAAC,GAAG,OAAO,iBAAiB,CAAC,CAAC;QACzC,IAAI,CAAC,MAAM,CAAC,GAAG,OAAO,WAAW,CAAC,CAAC;QACnC,IAAI,CAAC,MAAM,CAAC,GAAG,OAAO,WAAW,CAAC,CAAC;QACnC,IAAI,CAAC,MAAM,CAAC,GAAG,OAAO,kBAAkB,CAAC,CAAC;QAE1C,0BAA0B;QAC1B,MAAM,cAAc,GAAG,IAAA,iBAAQ,EAAC,IAAI,EAAE,cAAc,CAAC,CAAC;QACtD,cAAc,CAAC,IAAI,GAAG,mBAAmB,CAAC;QAC1C,cAAc,CAAC,OAAO,mCACjB,iBAAO,GACP,cAAc,CAAC,OAAO,CAC1B,CAAC;QACF,IAAA,kBAAS,EAAC,IAAI,EAAE,cAAc,EAAE,cAAc,CAAC,CAAC;QAEhD,gBAAgB;QAChB,IAAA,sBAAa,EAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE,OAAO,kCACrD,OAAO,KACV,UAAU,EAAV,kBAAU,IACV,CAAC;QAEH,mBAAmB;QACnB,IAAA,qCAA4B,EAC1B,IAAI,kCAEC,YAAY;YACf,sCAAsC;YACtC,yEAAyE;YACzE,8BAA8B,EAAE,QAAQ,KAE1C,EAAE,WAAW,EAAE,QAAQ,EAAE,CAC1B,CAAC;QAEF,IAAA,qCAA4B,EAAC,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,cAAc,CAAC,CAAC;QAErE,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;QAExB,OAAO,GAAG,EAAE;YACV,IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAC;YAC1B,IAAA,wBAAQ,EAAC,wBAAwB,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QAC3D,CAAC,CAAC;IACJ,CAAC;CAAA;AA1DD,4CA0DC;AAED,kBAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React, { Fragment, ReactElement } from 'react';
|
|
2
|
+
|
|
3
|
+
interface <%= formatName(name, true) %>Props {
|
|
4
|
+
// TODO: Describe props
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function <%= formatName(name, true) %>(props: <%= formatName(name, true) %>Props): ReactElement {
|
|
8
|
+
// TODO: Implement component
|
|
9
|
+
return <Fragment />;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './component';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.reactComponentGenerator = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
const inquirer = require("inquirer");
|
|
8
|
+
const lodash_1 = require("lodash");
|
|
9
|
+
const utils_1 = require("../../shared/utils");
|
|
10
|
+
function reactComponentGenerator(tree, options) {
|
|
11
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
12
|
+
const { libPath } = yield inquirer.prompt([
|
|
13
|
+
{
|
|
14
|
+
type: 'list',
|
|
15
|
+
name: 'libPath',
|
|
16
|
+
message: 'Choose the library path:',
|
|
17
|
+
choices: (0, utils_1.getNxLibsPaths)([utils_1.LibraryType.FEATURES, utils_1.LibraryType.UI]),
|
|
18
|
+
},
|
|
19
|
+
]);
|
|
20
|
+
options.name = options.name || (yield (0, utils_1.askQuestion)('Enter the name of the component (e.g: AppButton): '));
|
|
21
|
+
const libRootPath = `${libPath}/lib`;
|
|
22
|
+
const componentPath = options.subcomponent
|
|
23
|
+
? `${libRootPath}/components/${(0, lodash_1.kebabCase)(options.name)}`
|
|
24
|
+
: libRootPath;
|
|
25
|
+
(0, devkit_1.generateFiles)(tree, path.join(__dirname, `files`), componentPath, Object.assign(Object.assign({}, options), { formatName: utils_1.formatName }));
|
|
26
|
+
yield (0, devkit_1.formatFiles)(tree);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
exports.reactComponentGenerator = reactComponentGenerator;
|
|
30
|
+
exports.default = reactComponentGenerator;
|
|
31
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../plugin/src/generators/react-component/generator.ts"],"names":[],"mappings":";;;;AAAA,uCAA8D;AAC9D,6BAA6B;AAC7B,qCAAqC;AACrC,mCAAmC;AAEnC,8CAA0F;AAE1F,SAAsB,uBAAuB,CAC3C,IAAU,EACV,OAAsC;;QAEtC,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC;YACxC;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,0BAA0B;gBACnC,OAAO,EAAE,IAAA,sBAAc,EAAC,CAAC,mBAAW,CAAC,QAAQ,EAAE,mBAAW,CAAC,EAAE,CAAC,CAAC;aAChE;SACF,CAAC,CAAC;QAEH,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,KAAI,MAAM,IAAA,mBAAW,EAAC,oDAAoD,CAAC,CAAA,CAAC;QAEvG,MAAM,WAAW,GAAG,GAAG,OAAO,MAAM,CAAC;QACrC,MAAM,aAAa,GAAG,OAAO,CAAC,YAAY;YACxC,CAAC,CAAC,GAAG,WAAW,eAAe,IAAA,kBAAS,EAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACxD,CAAC,CAAC,WAAW,CAAC;QAEhB,IAAA,sBAAa,EAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE,aAAa,kCAAO,OAAO,KAAE,UAAU,EAAV,kBAAU,IAAG,CAAC;QAE9F,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CAAA;AAvBD,0DAuBC;AAED,kBAAe,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "ReactComponent",
|
|
4
|
+
"title": "",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"name": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "Name of the component",
|
|
10
|
+
"default": "",
|
|
11
|
+
"$default": {
|
|
12
|
+
"$source": "argv",
|
|
13
|
+
"index": 1
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"subcomponent": {
|
|
17
|
+
"type": "boolean",
|
|
18
|
+
"description": "Generate a folder for components",
|
|
19
|
+
"default": false
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"required": []
|
|
23
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React, { Fragment, ReactElement } from 'react';
|
|
2
|
+
|
|
3
|
+
interface <%= formatName(name, true) %>Props {
|
|
4
|
+
// TODO: Describe props
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function <%= formatName(name, true) %>(props: <%= formatName(name, true) %>Props): ReactElement {
|
|
8
|
+
// TODO: Implement component
|
|
9
|
+
return <Fragment />;
|
|
10
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.reactLibGenerator = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
const child_process_1 = require("child_process");
|
|
8
|
+
const utils_1 = require("../../shared/utils");
|
|
9
|
+
function reactLibGenerator(tree, options) {
|
|
10
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
11
|
+
if (!options.directory) {
|
|
12
|
+
options.app = options.app || (yield (0, utils_1.askQuestion)("Enter the name of the app (e.g: mobile) or 'shared': "));
|
|
13
|
+
options.scope = options.scope || (yield (0, utils_1.askQuestion)("Enter the scope (e.g: profile) or 'shared': "));
|
|
14
|
+
options.type = options.type || (yield (0, utils_1.askQuestion)("Enter the type (utils, ui, data-access or features): "));
|
|
15
|
+
options.name = options.name || (yield (0, utils_1.askQuestion)("Enter the name of the library (e.g: profile-settings): "));
|
|
16
|
+
}
|
|
17
|
+
const libPath = options.directory
|
|
18
|
+
? `libs/${options.directory}`
|
|
19
|
+
: `libs/${options.app}/${options.scope}/${options.type}/${options.name}`;
|
|
20
|
+
const command = `npx nx g @nx/expo:lib --skipPackageJson --unitTestRunner=none --projectNameAndRootFormat=derived ${libPath}`;
|
|
21
|
+
const commandWithOptions = options.dryRun ? command + ' --dry-run' : command;
|
|
22
|
+
(0, child_process_1.execSync)(commandWithOptions, { stdio: 'inherit' });
|
|
23
|
+
if (options.withComponent) {
|
|
24
|
+
const srcPath = `${libPath}/src`;
|
|
25
|
+
(0, devkit_1.generateFiles)(tree, path.join(__dirname, 'files'), srcPath, Object.assign(Object.assign({}, options), { name: (0, utils_1.getLibName)(libPath), formatName: utils_1.formatName }));
|
|
26
|
+
tree.write(`${srcPath}/index.ts`, "export * from './lib/component';");
|
|
27
|
+
}
|
|
28
|
+
yield (0, devkit_1.formatFiles)(tree);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
exports.reactLibGenerator = reactLibGenerator;
|
|
32
|
+
exports.default = reactLibGenerator;
|
|
33
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../plugin/src/generators/react-lib/generator.ts"],"names":[],"mappings":";;;;AAAA,uCAA8D;AAC9D,6BAA6B;AAE7B,iDAAyC;AACzC,8CAAyE;AAEzE,SAAsB,iBAAiB,CACrC,IAAU,EACV,OAAgC;;QAEhC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;YACvB,OAAO,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,KAAI,MAAM,IAAA,mBAAW,EAAC,uDAAuD,CAAC,CAAA,CAAA;YACvG,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,KAAI,MAAM,IAAA,mBAAW,EAAC,8CAA8C,CAAC,CAAA,CAAA;YAClG,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,KAAI,MAAM,IAAA,mBAAW,EAAC,uDAAuD,CAAC,CAAA,CAAA;YACzG,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,KAAI,MAAM,IAAA,mBAAW,EAAC,yDAAyD,CAAC,CAAA,CAAA;QAC7G,CAAC;QAED,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS;YAC/B,CAAC,CAAC,QAAQ,OAAO,CAAC,SAAS,EAAE;YAC7B,CAAC,CAAC,QAAQ,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QAC3E,MAAM,OAAO,GAAG,oGAAoG,OAAO,EAAE,CAAA;QAC7H,MAAM,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,GAAG,YAAY,CAAC,CAAC,CAAC,OAAO,CAAA;QAE5E,IAAA,wBAAQ,EAAC,kBAAkB,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QAEnD,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;YAC1B,MAAM,OAAO,GAAG,GAAG,OAAO,MAAM,CAAA;YAChC,IAAA,sBAAa,EAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE,OAAO,kCAAO,OAAO,KAAE,IAAI,EAAE,IAAA,kBAAU,EAAC,OAAO,CAAC,EAAE,UAAU,EAAV,kBAAU,IAAG,CAAC;YACnH,IAAI,CAAC,KAAK,CAAC,GAAG,OAAO,WAAW,EAAE,kCAAkC,CAAC,CAAC;QACxE,CAAC;QAED,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CAAA;AA1BD,8CA0BC;AAED,kBAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "ReactLib",
|
|
4
|
+
"title": "",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"directory": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "Directory for the library",
|
|
10
|
+
"$default": {
|
|
11
|
+
"$source": "argv",
|
|
12
|
+
"index": 0
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"app": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"description": "Name of the app",
|
|
18
|
+
"default": ""
|
|
19
|
+
},
|
|
20
|
+
"scope": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"description": "Name of the scope",
|
|
23
|
+
"default": ""
|
|
24
|
+
},
|
|
25
|
+
"type": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"description": "Type of the library",
|
|
28
|
+
"default": ""
|
|
29
|
+
},
|
|
30
|
+
"name": {
|
|
31
|
+
"type": "string",
|
|
32
|
+
"description": "Name of the library",
|
|
33
|
+
"default": ""
|
|
34
|
+
},
|
|
35
|
+
"withComponent": {
|
|
36
|
+
"type": "boolean",
|
|
37
|
+
"description": "Generate the library with 'lib/component.tsx' file",
|
|
38
|
+
"default": false
|
|
39
|
+
},
|
|
40
|
+
"dryRun": {
|
|
41
|
+
"type": "boolean",
|
|
42
|
+
"description": "Generate the library without creating files",
|
|
43
|
+
"default": false
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"required": []
|
|
47
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const askQuestion: (question: string) => Promise<string>;
|
|
2
|
+
export declare enum LibraryType {
|
|
3
|
+
UI = "ui",
|
|
4
|
+
DATA_ACCESS = "data-access",
|
|
5
|
+
FEATURES = "features",
|
|
6
|
+
UTILS = "utils"
|
|
7
|
+
}
|
|
8
|
+
export declare const getNxLibsPaths: (types: Array<LibraryType>) => any[];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getNxLibsPaths = exports.LibraryType = exports.askQuestion = void 0;
|
|
4
|
+
const readline = require("readline");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
const askQuestion = (question) => {
|
|
7
|
+
const rl = readline.createInterface({
|
|
8
|
+
input: process.stdin,
|
|
9
|
+
output: process.stdout,
|
|
10
|
+
});
|
|
11
|
+
return new Promise((resolve) => rl.question(question, (answer) => {
|
|
12
|
+
rl.close();
|
|
13
|
+
resolve(answer);
|
|
14
|
+
}));
|
|
15
|
+
};
|
|
16
|
+
exports.askQuestion = askQuestion;
|
|
17
|
+
var LibraryType;
|
|
18
|
+
(function (LibraryType) {
|
|
19
|
+
LibraryType["UI"] = "ui";
|
|
20
|
+
LibraryType["DATA_ACCESS"] = "data-access";
|
|
21
|
+
LibraryType["FEATURES"] = "features";
|
|
22
|
+
LibraryType["UTILS"] = "utils";
|
|
23
|
+
})(LibraryType || (exports.LibraryType = LibraryType = {}));
|
|
24
|
+
const getNxLibsPaths = (types) => {
|
|
25
|
+
const tsconfig = JSON.parse(fs.readFileSync('tsconfig.base.json', 'utf8'));
|
|
26
|
+
const libs = tsconfig.compilerOptions.paths;
|
|
27
|
+
return Object.values(libs)
|
|
28
|
+
.map((value) => value[0].replace('/index.ts', ''))
|
|
29
|
+
.filter((value) => types.some((type) => value.includes(type)));
|
|
30
|
+
};
|
|
31
|
+
exports.getNxLibsPaths = getNxLibsPaths;
|
|
32
|
+
//# sourceMappingURL=cli-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-utils.js","sourceRoot":"","sources":["../../../../../plugin/src/shared/utils/cli-utils.ts"],"names":[],"mappings":";;;AAAA,qCAAqC;AACrC,yBAAyB;AAElB,MAAM,WAAW,GAAG,CAAC,QAAgB,EAAmB,EAAE;IAC/D,MAAM,EAAE,GAAG,QAAQ,CAAC,eAAe,CAAC;QAClC,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,CAAC,CAAC;IAEH,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAC7B,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE;QAC/B,EAAE,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,CAAC,MAAM,CAAC,CAAC;IAClB,CAAC,CAAC,CACH,CAAC;AACJ,CAAC,CAAC;AAZW,QAAA,WAAW,eAYtB;AAEF,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,wBAAS,CAAA;IACT,0CAA2B,CAAA;IAC3B,oCAAqB,CAAA;IACrB,8BAAe,CAAA;AACjB,CAAC,EALW,WAAW,2BAAX,WAAW,QAKtB;AAEM,MAAM,cAAc,GAAG,CAAC,KAAyB,EAAE,EAAE;IAC1D,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC,CAAC;IAC3E,MAAM,IAAI,GAAG,QAAQ,CAAC,eAAe,CAAC,KAAK,CAAC;IAC5C,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;SACvB,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;SACjD,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACnE,CAAC,CAAA;AANY,QAAA,cAAc,kBAM1B"}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getProjectName = exports.formatName = void 0;
|
|
4
|
-
const formatName = (value) => value
|
|
3
|
+
exports.getLibName = exports.getProjectName = exports.formatName = void 0;
|
|
4
|
+
const formatName = (value, withoutSpaces = false) => value
|
|
5
5
|
.split('-')
|
|
6
6
|
.map((word) => `${word.charAt(0).toUpperCase()}${word.substring(1)}`)
|
|
7
|
-
.join(' ');
|
|
7
|
+
.join(withoutSpaces ? '' : ' ');
|
|
8
8
|
exports.formatName = formatName;
|
|
9
9
|
const getProjectName = (str) => {
|
|
10
10
|
const parts = str.split('@');
|
|
11
11
|
return parts.length > 1 ? parts[1].split('/')[0] : parts[0];
|
|
12
12
|
};
|
|
13
13
|
exports.getProjectName = getProjectName;
|
|
14
|
-
|
|
14
|
+
const getLibName = (path) => path.split('/').pop();
|
|
15
|
+
exports.getLibName = getLibName;
|
|
16
|
+
//# sourceMappingURL=format-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-utils.js","sourceRoot":"","sources":["../../../../../plugin/src/shared/utils/format-utils.ts"],"names":[],"mappings":";;;AAAO,MAAM,UAAU,GAAG,CAAC,KAAa,EAAE,aAAa,GAAG,KAAK,EAAE,EAAE,CACjE,KAAK;KACF,KAAK,CAAC,GAAG,CAAC;KACV,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;KACpE,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AAJvB,QAAA,UAAU,cAIa;AAE7B,MAAM,cAAc,GAAG,CAAC,GAAW,EAAE,EAAE;IAC5C,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAE7B,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC9D,CAAC,CAAC;AAJW,QAAA,cAAc,kBAIzB;AAEK,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;AAArD,QAAA,UAAU,cAA2C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../plugin/src/shared/utils/index.ts"],"names":[],"mappings":";;;AAAA,yDAA+B;AAC/B,sDAA4B"}
|
package/src/shared/utils.d.ts
DELETED
package/src/shared/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../plugin/src/shared/utils.ts"],"names":[],"mappings":";;;AAAO,MAAM,UAAU,GAAG,CAAC,KAAa,EAAE,EAAE,CAC1C,KAAK;KACF,KAAK,CAAC,GAAG,CAAC;KACV,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;KACpE,IAAI,CAAC,GAAG,CAAC,CAAC;AAJF,QAAA,UAAU,cAIR;AAER,MAAM,cAAc,GAAG,CAAC,GAAW,EAAE,EAAE;IAC5C,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAE7B,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC9D,CAAC,CAAC;AAJW,QAAA,cAAc,kBAIzB"}
|