@ronas-it/nx-generators 0.5.0 → 0.5.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/package.json +1 -1
- package/src/generators/expo-app/app-files/jest.config.ts.template +20 -0
- package/src/generators/expo-app/app-files/test-setup.ts.template +1 -0
- package/src/generators/expo-app/app-files/tsconfig.app.json.template +10 -0
- package/src/generators/expo-app/generator.js +5 -3
- package/src/generators/expo-app/generator.js.map +1 -1
- package/src/shared/dependencies.d.ts +4 -0
- package/src/shared/dependencies.js +4 -0
- package/src/shared/dependencies.js.map +1 -1
- package/src/shared/generators/auth/lib-files/shared/data-access/api/src/index.ts.template +1 -0
- package/src/shared/generators/auth/lib-files/shared/data-access/api/src/lib/index.ts.template +3 -0
- package/src/shared/generators/auth/lib-files/shared/data-access/api/src/lib/profile/api.ts.template +52 -0
- package/src/shared/generators/auth/lib-files/shared/data-access/api/src/lib/profile/config.ts.template +7 -0
- package/src/shared/generators/auth/lib-files/shared/data-access/api/src/lib/profile/index.ts.template +2 -0
- package/src/shared/generators/auth/lib-files/shared/data-access/api/src/lib/profile/models/get-profile-request.ts.template +9 -0
- package/src/shared/generators/auth/lib-files/shared/data-access/api/src/lib/profile/models/index.ts.template +1 -0
- package/src/shared/generators/auth/lib-files/shared/data-access/api/src/lib/profile/types/index.ts.template +1 -0
- package/src/shared/generators/auth/lib-files/shared/data-access/api/src/lib/profile/types/relation.ts.template +1 -0
- package/src/shared/generators/auth/lib-files/shared/data-access/auth/src/lib/store/listener.ts.template +4 -1
- package/src/shared/generators/rn-styles/lib-files/shared/ui/styles/src/index.ts.template +1 -0
- package/src/shared/generators/store/expo-app/lib-files/shared/data-access/store/src/store.ts.template +5 -3
package/package.json
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
displayName: '<%= appDirectory %>',
|
|
3
|
+
resolver: '@nx/jest/plugins/resolver',
|
|
4
|
+
preset: 'jest-expo',
|
|
5
|
+
moduleFileExtensions: ['ts', 'js', 'html', 'tsx', 'jsx'],
|
|
6
|
+
setupFilesAfterEnv: ['<rootDir>/test-setup.ts'],
|
|
7
|
+
moduleNameMapper: {
|
|
8
|
+
'\\.svg$': '@nx/expo/plugins/jest/svg-mock',
|
|
9
|
+
},
|
|
10
|
+
transform: {
|
|
11
|
+
'.[jt]sx?$': [
|
|
12
|
+
'babel-jest',
|
|
13
|
+
{
|
|
14
|
+
configFile: __dirname + '/.babelrc.js',
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
'^.+.(bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp|ttf|otf|m4v|mov|mp4|mpeg|mpg|webm|aac|aiff|caf|m4a|mp3|wav|html|pdf|obj)$':
|
|
18
|
+
require.resolve('jest-expo/src/preset/assetFileTransformer.js'),
|
|
19
|
+
},
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-native/extend-expect';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "../../dist/out-tsc",
|
|
5
|
+
"types": ["node"]
|
|
6
|
+
},
|
|
7
|
+
"files": ["../../node_modules/@nx/expo/typings/svg.d.ts"],
|
|
8
|
+
"exclude": ["jest.config.ts", "**/*.spec.ts", "**/*.spec.tsx", "test-setup.ts"],
|
|
9
|
+
"include": ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"]
|
|
10
|
+
}
|
|
@@ -41,6 +41,8 @@ function expoAppGenerator(tree, options) {
|
|
|
41
41
|
tree.delete(`${appRoot}/app.json`);
|
|
42
42
|
tree.delete(`${appRoot}/eas.json`);
|
|
43
43
|
tree.delete(`${appRoot}/metro.config.js`);
|
|
44
|
+
tree.delete(`${appRoot}/jest.config.ts`);
|
|
45
|
+
tree.delete(`${appRoot}/tsconfig.app.json`);
|
|
44
46
|
// Update app package.json
|
|
45
47
|
const appPackageJson = (0, devkit_1.readJson)(tree, appPackagePath);
|
|
46
48
|
appPackageJson.main = 'expo-router/entry';
|
|
@@ -48,10 +50,10 @@ function expoAppGenerator(tree, options) {
|
|
|
48
50
|
(0, devkit_1.writeJson)(tree, appPackagePath, appPackageJson);
|
|
49
51
|
// Add app files
|
|
50
52
|
(0, devkit_1.generateFiles)(tree, path.join(__dirname, 'app-files'), appRoot, Object.assign(Object.assign({}, options), { formatName: utils_1.formatName,
|
|
51
|
-
formatAppIdentifier: utils_1.formatAppIdentifier, formatDirectory: () => libPath, isUIKittenEnabled: false }));
|
|
53
|
+
formatAppIdentifier: utils_1.formatAppIdentifier, formatDirectory: () => libPath, isUIKittenEnabled: false, appDirectory: options.directory }));
|
|
52
54
|
// Add dependencies
|
|
53
|
-
(0, devkit_1.addDependenciesToPackageJson)(tree, Object.assign(Object.assign({}, dependencies_1.dependencies['expo-app']), dependencies_1.dependencies['expo-app-root']), dependencies_1.devDependencies['expo-app-root']);
|
|
54
|
-
(0, devkit_1.addDependenciesToPackageJson)(tree, dependencies_1.dependencies['expo-app'],
|
|
55
|
+
(0, devkit_1.addDependenciesToPackageJson)(tree, Object.assign(Object.assign({}, dependencies_1.dependencies['expo-app']), dependencies_1.dependencies['expo-app-root']), Object.assign(Object.assign({}, dependencies_1.devDependencies['expo-app']), dependencies_1.devDependencies['expo-app-root']));
|
|
56
|
+
(0, devkit_1.addDependenciesToPackageJson)(tree, dependencies_1.dependencies['expo-app'], dependencies_1.devDependencies['expo-app'], appPackagePath);
|
|
55
57
|
yield (0, devkit_1.formatFiles)(tree);
|
|
56
58
|
return () => {
|
|
57
59
|
(0, devkit_1.installPackagesTask)(tree);
|
|
@@ -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,uCAAg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C;QAC5F,CAAC,CAAC;IACJ,CAAC;CAAA;AArFD,4CAqFC;AAED,kBAAe,gBAAgB,CAAC"}
|
|
@@ -9,6 +9,7 @@ export declare const dependencies: {
|
|
|
9
9
|
'expo-status-bar': string;
|
|
10
10
|
'expo-updates': string;
|
|
11
11
|
'expo-insights': string;
|
|
12
|
+
"lodash-es": string;
|
|
12
13
|
};
|
|
13
14
|
'expo-app-root': {
|
|
14
15
|
'react-native-svg-transformer': string;
|
|
@@ -50,6 +51,9 @@ export declare const devDependencies: {
|
|
|
50
51
|
'@typescript-eslint/parser': string;
|
|
51
52
|
'tsc-files': string;
|
|
52
53
|
};
|
|
54
|
+
'expo-app': {
|
|
55
|
+
'@types/lodash': string;
|
|
56
|
+
};
|
|
53
57
|
'expo-app-root': {
|
|
54
58
|
'cross-env': string;
|
|
55
59
|
};
|
|
@@ -12,6 +12,7 @@ exports.dependencies = {
|
|
|
12
12
|
'expo-status-bar': '^1.12.1',
|
|
13
13
|
'expo-updates': '^0.25.17',
|
|
14
14
|
'expo-insights': '~0.7.0',
|
|
15
|
+
"lodash-es": "^4.17.21"
|
|
15
16
|
},
|
|
16
17
|
'expo-app-root': {
|
|
17
18
|
// Need new version to fix this error:
|
|
@@ -55,6 +56,9 @@ exports.devDependencies = {
|
|
|
55
56
|
'@typescript-eslint/parser': '^7.13.1',
|
|
56
57
|
'tsc-files': '^1.1.4',
|
|
57
58
|
},
|
|
59
|
+
'expo-app': {
|
|
60
|
+
'@types/lodash': '^4.14.194',
|
|
61
|
+
},
|
|
58
62
|
'expo-app-root': {
|
|
59
63
|
'cross-env': '^7.0.3'
|
|
60
64
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../../../plugin/src/shared/dependencies.ts"],"names":[],"mappings":";;;AAAa,QAAA,YAAY,GAAG;IAC1B,UAAU,EAAE;QACV,uCAAuC,EAAE,QAAQ;QACjD,gBAAgB,EAAE,SAAS;QAC3B,a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,SAAS;QAChC,2BAA2B,EAAE,QAAQ;QACrC,4BAA4B,EAAE,QAAQ;QACtC,8BAA8B,EAAE,QAAQ;QACxC,kCAAkC,EAAE,SAAS;QAC7C,2BAA2B,EAAE,SAAS;QACtC,WAAW,EAAE,QAAQ;KACtB;IACD,UAAU,EAAE;QACV,eAAe,EAAE,WAAW;KAC7B;IACD,eAAe,EAAE;QACf,WAAW,EAAE,QAAQ;KACtB;IACD,aAAa,EAAE;QACb,UAAU,EAAE,SAAS;KACtB;IACD,MAAM,EAAE;QACN,cAAc,EAAE,OAAO;KACxB;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib';
|
package/src/shared/generators/auth/lib-files/shared/data-access/api/src/lib/profile/api.ts.template
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { prepareRequestParams } from '@ronas-it/rtkq-entity-api';
|
|
2
|
+
import { plainToInstance } from 'class-transformer';
|
|
3
|
+
import { axiosBaseQuery, createAppApi } from '<%= formatDirectory() %>/shared/data-access/api-client';
|
|
4
|
+
import { User } from '../user';
|
|
5
|
+
import { profileApiConfig } from './config';
|
|
6
|
+
import { GetProfileRequest } from './models';
|
|
7
|
+
|
|
8
|
+
export enum ProfileApiTag {
|
|
9
|
+
PROFILE = 'profile',
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const profileApi = createAppApi({
|
|
13
|
+
reducerPath: 'profile',
|
|
14
|
+
tagTypes: [ProfileApiTag.PROFILE],
|
|
15
|
+
baseQuery: axiosBaseQuery,
|
|
16
|
+
endpoints: (builder) => ({
|
|
17
|
+
getProfile: builder.query<User, void>({
|
|
18
|
+
query: () => {
|
|
19
|
+
const params = prepareRequestParams(profileApiConfig.defaultGetProfileParams, GetProfileRequest);
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
method: 'GET',
|
|
23
|
+
url: '/profile',
|
|
24
|
+
params,
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
transformResponse: (response) => plainToInstance(User, response),
|
|
28
|
+
providesTags: [ProfileApiTag.PROFILE],
|
|
29
|
+
}),
|
|
30
|
+
updateProfile: builder.mutation<void, User>({
|
|
31
|
+
query: (params) => {
|
|
32
|
+
const request = prepareRequestParams(params, User);
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
method: 'PUT',
|
|
36
|
+
url: '/profile',
|
|
37
|
+
data: request,
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
invalidatesTags: [ProfileApiTag.PROFILE],
|
|
41
|
+
}),
|
|
42
|
+
deleteProfile: builder.mutation<void, void>({
|
|
43
|
+
query: () => {
|
|
44
|
+
return {
|
|
45
|
+
method: 'DELETE',
|
|
46
|
+
url: '/profile',
|
|
47
|
+
};
|
|
48
|
+
},
|
|
49
|
+
invalidatesTags: [ProfileApiTag.PROFILE],
|
|
50
|
+
}),
|
|
51
|
+
}),
|
|
52
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { EntityRequest } from '@ronas-it/rtkq-entity-api';
|
|
2
|
+
import { ProfileRelation } from '../types';
|
|
3
|
+
|
|
4
|
+
export class GetProfileRequest extends EntityRequest<ProfileRelation> {
|
|
5
|
+
constructor(model: GetProfileRequest) {
|
|
6
|
+
super(model);
|
|
7
|
+
Object.assign(this, model);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './get-profile-request';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './relation';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ProfileRelation = 'avatar.media';
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from '@ronas-it/axios-api-client';
|
|
8
8
|
import { storeActions } from '@ronas-it/rtkq-entity-api';
|
|
9
9
|
import { DateTime } from 'luxon';
|
|
10
|
-
import { authApi, LogInResponse } from '<%= formatDirectory() %>/shared/data-access/api';
|
|
10
|
+
import { authApi, profileApi, LogInResponse } from '<%= formatDirectory() %>/shared/data-access/api';
|
|
11
11
|
import { apiService, configuration } from '<%= formatDirectory() %>/shared/data-access/api-client';
|
|
12
12
|
import { appStorageService } from '<%= formatDirectory() %>/shared/data-access/storage';
|
|
13
13
|
import { authActions, authReducerPath, authSelectors, AuthState } from './slice';
|
|
@@ -30,6 +30,7 @@ authListenerMiddleware.startListening({
|
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
dispatch(authActions.setIsAppReady(true));
|
|
33
|
+
isAuthenticated && dispatch(profileApi.endpoints.getProfile.initiate());
|
|
33
34
|
},
|
|
34
35
|
});
|
|
35
36
|
|
|
@@ -76,6 +77,8 @@ authListenerMiddleware.startListening({
|
|
|
76
77
|
dispatch(authActions.setIsAuthenticated(false));
|
|
77
78
|
dispatch(authActions.setTokenExpiresAt(null));
|
|
78
79
|
dispatch(authActions.setToken(null));
|
|
80
|
+
|
|
81
|
+
dispatch(profileApi.util.resetApiState());
|
|
79
82
|
},
|
|
80
83
|
});
|
|
81
84
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib';
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
AppStateFromRootReducer,
|
|
5
5
|
createStoreInitializer,
|
|
6
6
|
} from '@ronas-it/rtkq-entity-api';
|
|
7
|
-
import { authApi } from '<%= formatDirectory() %>/shared/data-access/api';
|
|
7
|
+
import { authApi, profileApi } from '<%= formatDirectory() %>/shared/data-access/api';
|
|
8
8
|
import {
|
|
9
9
|
authListenerMiddleware,
|
|
10
10
|
authReducer,
|
|
@@ -16,12 +16,14 @@ export type AppState = AppStateFromRootReducer<typeof rootReducer>;
|
|
|
16
16
|
|
|
17
17
|
const rootReducer = {
|
|
18
18
|
[authApi.reducerPath]: authApi.reducer,
|
|
19
|
-
[authReducerPath]: authReducer
|
|
19
|
+
[authReducerPath]: authReducer,
|
|
20
|
+
[profileApi.reducerPath]: profileApi.reducer,
|
|
20
21
|
};
|
|
21
22
|
|
|
22
23
|
const middlewares = [
|
|
23
24
|
authApi.middleware,
|
|
24
|
-
authListenerMiddleware.middleware
|
|
25
|
+
authListenerMiddleware.middleware,
|
|
26
|
+
profileApi.middleware
|
|
25
27
|
];
|
|
26
28
|
|
|
27
29
|
const reactotron = setupReactotron('my-app');
|