@aws-amplify/amplify-util-uibuilder 1.2.0-uibuilder-ts.0 → 1.2.2-mapsto.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.
Files changed (85) hide show
  1. package/CHANGELOG.md +34 -2
  2. package/lib/commands/cloneComponentsFromEnv.d.ts +3 -0
  3. package/lib/commands/cloneComponentsFromEnv.d.ts.map +1 -0
  4. package/lib/commands/cloneComponentsFromEnv.js +68 -0
  5. package/lib/commands/cloneComponentsFromEnv.js.map +1 -0
  6. package/lib/commands/generateComponents.d.ts +3 -0
  7. package/lib/commands/generateComponents.d.ts.map +1 -0
  8. package/lib/commands/generateComponents.js +50 -0
  9. package/lib/commands/generateComponents.js.map +1 -0
  10. package/lib/commands/help.d.ts +2 -0
  11. package/lib/commands/help.d.ts.map +1 -0
  12. package/lib/commands/help.js +9 -0
  13. package/lib/commands/help.js.map +1 -0
  14. package/lib/commands/utils/createUiBuilderComponent.d.ts +5 -0
  15. package/lib/commands/utils/createUiBuilderComponent.d.ts.map +1 -0
  16. package/lib/commands/utils/createUiBuilderComponent.js +64 -0
  17. package/lib/commands/utils/createUiBuilderComponent.js.map +1 -0
  18. package/lib/commands/utils/extractArgs.d.ts +11 -0
  19. package/lib/commands/utils/extractArgs.d.ts.map +1 -0
  20. package/lib/commands/utils/extractArgs.js +26 -0
  21. package/lib/commands/utils/extractArgs.js.map +1 -0
  22. package/lib/commands/utils/getUiBuilderComponentsPath.d.ts +3 -0
  23. package/lib/commands/utils/getUiBuilderComponentsPath.d.ts.map +1 -0
  24. package/lib/commands/utils/getUiBuilderComponentsPath.js +20 -0
  25. package/lib/commands/utils/getUiBuilderComponentsPath.js.map +1 -0
  26. package/lib/commands/utils/notifyMissingPackages.d.ts +3 -0
  27. package/lib/commands/utils/notifyMissingPackages.d.ts.map +1 -0
  28. package/lib/commands/utils/notifyMissingPackages.js +45 -0
  29. package/lib/commands/utils/notifyMissingPackages.js.map +1 -0
  30. package/lib/commands/utils/shouldRenderComponents.d.ts +3 -0
  31. package/lib/commands/utils/shouldRenderComponents.d.ts.map +1 -0
  32. package/lib/commands/utils/shouldRenderComponents.js +34 -0
  33. package/lib/commands/utils/shouldRenderComponents.js.map +1 -0
  34. package/lib/commands/utils/syncAmplifyUiBuilderComponents.d.ts +31 -0
  35. package/lib/commands/utils/syncAmplifyUiBuilderComponents.d.ts.map +1 -0
  36. package/lib/commands/utils/syncAmplifyUiBuilderComponents.js +116 -0
  37. package/lib/commands/utils/syncAmplifyUiBuilderComponents.js.map +1 -0
  38. package/lib/commands/version.d.ts +2 -0
  39. package/lib/commands/version.d.ts.map +1 -0
  40. package/lib/commands/version.js +32 -0
  41. package/lib/commands/version.js.map +1 -0
  42. package/lib/event-handlers/handle-PostEnvAdd.d.ts +3 -0
  43. package/lib/event-handlers/handle-PostEnvAdd.d.ts.map +1 -0
  44. package/lib/event-handlers/handle-PostEnvAdd.js +17 -0
  45. package/lib/event-handlers/handle-PostEnvAdd.js.map +1 -0
  46. package/lib/event-handlers/handle-PostPull.d.ts +3 -0
  47. package/lib/event-handlers/handle-PostPull.d.ts.map +1 -0
  48. package/lib/event-handlers/handle-PostPull.js +14 -0
  49. package/lib/event-handlers/handle-PostPull.js.map +1 -0
  50. package/lib/index.d.ts +6 -0
  51. package/lib/index.d.ts.map +1 -0
  52. package/lib/index.js +22 -0
  53. package/lib/index.js.map +1 -0
  54. package/package.json +44 -8
  55. package/src/__tests__/cloneComponentsFromEnv.test.ts +49 -0
  56. package/src/__tests__/createUiBuilderComponent.test.ts +60 -0
  57. package/src/__tests__/generateComponents.test.ts +50 -0
  58. package/src/__tests__/handleEvents.test.ts +21 -0
  59. package/src/__tests__/help.test.ts +10 -0
  60. package/src/__tests__/mock.json +1 -0
  61. package/src/__tests__/notifyMissingPackages.test.ts +73 -0
  62. package/src/__tests__/package.json +3 -0
  63. package/{commands/utils/__tests__/shouldRenderComponents.test.js → src/__tests__/shouldRenderComponents.test.ts} +3 -2
  64. package/src/__tests__/syncAmplifyUiComponents.test.ts +150 -0
  65. package/src/__tests__/version.test.ts +10 -0
  66. package/{commands/cloneComponentsFromEnv.js → src/commands/cloneComponentsFromEnv.ts} +15 -19
  67. package/{commands/generateComponents.js → src/commands/generateComponents.ts} +10 -12
  68. package/src/commands/help.ts +5 -0
  69. package/{commands/utils/createUiBuilderComponent.js → src/commands/utils/createUiBuilderComponent.ts} +16 -20
  70. package/{commands/utils/extractArgs.js → src/commands/utils/extractArgs.ts} +3 -5
  71. package/{commands/utils/getUiBuilderComponentsPath.js → src/commands/utils/getUiBuilderComponentsPath.ts} +5 -8
  72. package/src/commands/utils/notifyMissingPackages.ts +40 -0
  73. package/{commands/utils/shouldRenderComponents.js → src/commands/utils/shouldRenderComponents.ts} +5 -8
  74. package/{commands/utils/syncAmplifyUiBuilderComponents.js → src/commands/utils/syncAmplifyUiBuilderComponents.ts} +23 -26
  75. package/src/commands/version.ts +6 -0
  76. package/{event-handlers/handle-PostEnvAdd.js → src/event-handlers/handle-PostEnvAdd.ts} +3 -6
  77. package/{event-handlers/handle-PostPull.js → src/event-handlers/handle-PostPull.ts} +3 -6
  78. package/{index.js → src/index.ts} +6 -10
  79. package/tsconfig.json +9 -0
  80. package/tsconfig.tsbuildinfo +1 -0
  81. package/commands/help.js +0 -7
  82. package/commands/utils/__tests__/createUiComponents.test.js +0 -46
  83. package/commands/utils/__tests__/syncAmplifyUiComponents.test.js +0 -67
  84. package/commands/utils/notifyMissingPackages.js +0 -28
  85. package/commands/version.js +0 -10
package/commands/help.js DELETED
@@ -1,7 +0,0 @@
1
- async function run(context) {
2
- context.print.info('Supported commands: generateComponents, cloneComponentsFromEnv');
3
- }
4
-
5
- module.exports = {
6
- run,
7
- };
@@ -1,46 +0,0 @@
1
- const context = {
2
- exeInfo: {
3
- projectConfig: {
4
- providers: ['awscloudformation'],
5
- frontend: 'javascript',
6
- javascript: {
7
- framework: 'react',
8
- config: {
9
- SourceDir: 'src',
10
- },
11
- },
12
- },
13
- },
14
- parameters: {
15
- argv: [],
16
- },
17
- input: {},
18
- };
19
- const schema = {
20
- appId: 'd37nrm8rzt3oek',
21
- bindingProperties: {},
22
- componentType: 'Box',
23
- environmentName: 'staging',
24
- id: 's-s4mU579Ycf6JGHwhqT',
25
- name: 'aawwdd',
26
- overrides: {},
27
- properties: {},
28
- variants: [],
29
- };
30
-
31
- describe('should create ui builder components', () => {
32
- let codegen;
33
- beforeEach(() => {
34
- jest.mock('@aws-amplify/codegen-ui');
35
- codegen = require('@aws-amplify/codegen-ui');
36
- const renderSchemaToTemplateMock = jest.fn();
37
- codegen.StudioTemplateRendererManager.mockImplementation(() => ({
38
- renderSchemaToTemplate: renderSchemaToTemplateMock,
39
- }));
40
- });
41
- it('calls the renderManager', async () => {
42
- const { createUiBuilderComponent } = require('../createUiBuilderComponent');
43
- await createUiBuilderComponent(context, schema);
44
- expect(new codegen.StudioTemplateRendererManager().renderSchemaToTemplate).toBeCalled();
45
- });
46
- });
@@ -1,67 +0,0 @@
1
- const aws = require('aws-sdk');
2
- const { FeatureFlags } = require('amplify-cli-core');
3
- FeatureFlags.getBoolean = () => false;
4
- FeatureFlags.getNumber = () => 0;
5
- const sc = require('../createUiBuilderComponent');
6
- const context = {
7
- exeInfo: {
8
- projectConfig: {
9
- javascript: {
10
- config: {
11
- SourceDir: 'src',
12
- },
13
- },
14
- },
15
- },
16
- amplify: {
17
- invokePluginMethod: () => ({}),
18
- },
19
- parameters: {
20
- argv: [],
21
- },
22
- input: {},
23
- };
24
-
25
- describe('should sync amplify ui builder components', () => {
26
- beforeEach(() => {
27
- aws.AmplifyUIBuilder = jest.fn(() => ({
28
- exportComponents: jest.fn(() => ({
29
- promise: jest.fn(() => ({
30
- entities: [
31
- {
32
- appId: 'd37nrm8rzt3oek',
33
- bindingProperties: {},
34
- componentType: 'Box',
35
- environmentName: 'staging',
36
- id: 's-s4mU579Ycf6JGHwhqT',
37
- name: 'aawwdd',
38
- overrides: {},
39
- properties: {},
40
- variants: [],
41
- },
42
- ],
43
- })),
44
- })),
45
- exportThemes: jest.fn(() => ({
46
- promise: jest.fn(() => ({
47
- entities: [],
48
- })),
49
- })),
50
- }));
51
-
52
- sc.createUiBuilderComponent = jest.fn();
53
- });
54
-
55
- it('pulls components from aws-sdk and passes them to createUiBuilderComponent', () => {
56
- const { generateUiBuilderComponents } = require('../syncAmplifyUiBuilderComponents');
57
- generateUiBuilderComponents(context, []);
58
- });
59
-
60
- it('does not throw an error when createUiBuilderComponent fails', () => {
61
- sc.createUiBuilderComponent = jest.fn(() => {
62
- throw new Error('ahhh!');
63
- });
64
- const { generateUiBuilderComponents } = require('../syncAmplifyUiBuilderComponents');
65
- expect(async () => generateUiBuilderComponents(context, [])).not.toThrow();
66
- });
67
- });
@@ -1,28 +0,0 @@
1
- const { pathManager, JSONUtilities } = require('amplify-cli-core');
2
- const fs = require('fs-extra');
3
- const path = require('path');
4
- const { extractArgs } = require('./extractArgs');
5
- const REQUIRED_PACKAGES = ['@aws-amplify/ui-react', 'aws-amplify'];
6
-
7
- const notifyMissingPackages = context => {
8
- const args = extractArgs(context);
9
- const localEnvFilePath = args.localEnvFilePath ? args.localEnvFilePath : pathManager.getLocalEnvFilePath();
10
- const localEnvJson = JSONUtilities.readJson(localEnvFilePath);
11
- const packageJsonPath = path.join(localEnvJson.projectPath, 'package.json');
12
- if (!fs.existsSync(packageJsonPath)) {
13
- return;
14
- }
15
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath).toString());
16
- REQUIRED_PACKAGES.forEach(packageName => {
17
- const packageIsInstalled = Object.keys(packageJson.dependencies).includes(packageName);
18
- if (!packageIsInstalled) {
19
- console.warn(
20
- `UIBuilder components required "${packageName}" that is not in your package.json. Please run \`npm install ${packageName}\``,
21
- );
22
- }
23
- });
24
- };
25
-
26
- module.exports = {
27
- notifyMissingPackages,
28
- };
@@ -1,10 +0,0 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
-
4
- async function run(context) {
5
- context.print.info(require(path.join(__dirname, '..', 'package.json')).version);
6
- }
7
-
8
- module.exports = {
9
- run,
10
- };