@aws-amplify/amplify-util-uibuilder 1.2.0-uibuilder-ts.0 → 1.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/CHANGELOG.md +18 -2
- package/lib/commands/cloneComponentsFromEnv.d.ts +3 -0
- package/lib/commands/cloneComponentsFromEnv.d.ts.map +1 -0
- package/lib/commands/cloneComponentsFromEnv.js +68 -0
- package/lib/commands/cloneComponentsFromEnv.js.map +1 -0
- package/lib/commands/generateComponents.d.ts +3 -0
- package/lib/commands/generateComponents.d.ts.map +1 -0
- package/lib/commands/generateComponents.js +50 -0
- package/lib/commands/generateComponents.js.map +1 -0
- package/lib/commands/help.d.ts +2 -0
- package/lib/commands/help.d.ts.map +1 -0
- package/lib/commands/help.js +9 -0
- package/lib/commands/help.js.map +1 -0
- package/lib/commands/utils/createUiBuilderComponent.d.ts +5 -0
- package/lib/commands/utils/createUiBuilderComponent.d.ts.map +1 -0
- package/lib/commands/utils/createUiBuilderComponent.js +64 -0
- package/lib/commands/utils/createUiBuilderComponent.js.map +1 -0
- package/lib/commands/utils/extractArgs.d.ts +11 -0
- package/lib/commands/utils/extractArgs.d.ts.map +1 -0
- package/lib/commands/utils/extractArgs.js +26 -0
- package/lib/commands/utils/extractArgs.js.map +1 -0
- package/lib/commands/utils/getUiBuilderComponentsPath.d.ts +3 -0
- package/lib/commands/utils/getUiBuilderComponentsPath.d.ts.map +1 -0
- package/lib/commands/utils/getUiBuilderComponentsPath.js +20 -0
- package/lib/commands/utils/getUiBuilderComponentsPath.js.map +1 -0
- package/lib/commands/utils/notifyMissingPackages.d.ts +3 -0
- package/lib/commands/utils/notifyMissingPackages.d.ts.map +1 -0
- package/lib/commands/utils/notifyMissingPackages.js +45 -0
- package/lib/commands/utils/notifyMissingPackages.js.map +1 -0
- package/lib/commands/utils/shouldRenderComponents.d.ts +3 -0
- package/lib/commands/utils/shouldRenderComponents.d.ts.map +1 -0
- package/lib/commands/utils/shouldRenderComponents.js +34 -0
- package/lib/commands/utils/shouldRenderComponents.js.map +1 -0
- package/lib/commands/utils/syncAmplifyUiBuilderComponents.d.ts +31 -0
- package/lib/commands/utils/syncAmplifyUiBuilderComponents.d.ts.map +1 -0
- package/lib/commands/utils/syncAmplifyUiBuilderComponents.js +116 -0
- package/lib/commands/utils/syncAmplifyUiBuilderComponents.js.map +1 -0
- package/lib/commands/version.d.ts +2 -0
- package/lib/commands/version.d.ts.map +1 -0
- package/lib/commands/version.js +32 -0
- package/lib/commands/version.js.map +1 -0
- package/lib/event-handlers/handle-PostEnvAdd.d.ts +3 -0
- package/lib/event-handlers/handle-PostEnvAdd.d.ts.map +1 -0
- package/lib/event-handlers/handle-PostEnvAdd.js +17 -0
- package/lib/event-handlers/handle-PostEnvAdd.js.map +1 -0
- package/lib/event-handlers/handle-PostPull.d.ts +3 -0
- package/lib/event-handlers/handle-PostPull.d.ts.map +1 -0
- package/lib/event-handlers/handle-PostPull.js +14 -0
- package/lib/event-handlers/handle-PostPull.js.map +1 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +22 -0
- package/lib/index.js.map +1 -0
- package/package.json +35 -5
- package/src/__tests__/cloneComponentsFromEnv.test.ts +49 -0
- package/src/__tests__/createUiBuilderComponent.test.ts +60 -0
- package/src/__tests__/generateComponents.test.ts +50 -0
- package/src/__tests__/handleEvents.test.ts +21 -0
- package/src/__tests__/help.test.ts +10 -0
- package/src/__tests__/mock.json +1 -0
- package/src/__tests__/notifyMissingPackages.test.ts +73 -0
- package/src/__tests__/package.json +3 -0
- package/{commands/utils/__tests__/shouldRenderComponents.test.js → src/__tests__/shouldRenderComponents.test.ts} +3 -2
- package/src/__tests__/syncAmplifyUiComponents.test.ts +150 -0
- package/src/__tests__/version.test.ts +10 -0
- package/{commands/cloneComponentsFromEnv.js → src/commands/cloneComponentsFromEnv.ts} +15 -19
- package/{commands/generateComponents.js → src/commands/generateComponents.ts} +10 -12
- package/src/commands/help.ts +5 -0
- package/{commands/utils/createUiBuilderComponent.js → src/commands/utils/createUiBuilderComponent.ts} +16 -20
- package/{commands/utils/extractArgs.js → src/commands/utils/extractArgs.ts} +3 -5
- package/{commands/utils/getUiBuilderComponentsPath.js → src/commands/utils/getUiBuilderComponentsPath.ts} +5 -8
- package/src/commands/utils/notifyMissingPackages.ts +40 -0
- package/{commands/utils/shouldRenderComponents.js → src/commands/utils/shouldRenderComponents.ts} +5 -8
- package/{commands/utils/syncAmplifyUiBuilderComponents.js → src/commands/utils/syncAmplifyUiBuilderComponents.ts} +23 -26
- package/src/commands/version.ts +6 -0
- package/{event-handlers/handle-PostEnvAdd.js → src/event-handlers/handle-PostEnvAdd.ts} +3 -6
- package/{event-handlers/handle-PostPull.js → src/event-handlers/handle-PostPull.ts} +3 -6
- package/{index.js → src/index.ts} +6 -10
- package/tsconfig.json +9 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/commands/help.js +0 -7
- package/commands/utils/__tests__/createUiComponents.test.js +0 -46
- package/commands/utils/__tests__/syncAmplifyUiComponents.test.js +0 -67
- package/commands/utils/notifyMissingPackages.js +0 -28
- package/commands/version.js +0 -10
package/commands/help.js
DELETED
|
@@ -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
|
-
};
|