@aws-amplify/amplify-util-uibuilder 1.1.3-beta.6 → 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 +14 -3
- 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 +37 -7
- 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/src/commands/cloneComponentsFromEnv.ts +72 -0
- package/{commands/generateComponents.js → src/commands/generateComponents.ts} +13 -15
- package/src/commands/help.ts +5 -0
- package/src/commands/utils/createUiBuilderComponent.ts +75 -0
- 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/src/commands/utils/shouldRenderComponents.ts +34 -0
- package/{commands/utils/syncAmplifyUiBuilderComponents.js → src/commands/utils/syncAmplifyUiBuilderComponents.ts} +37 -43
- package/src/commands/version.ts +6 -0
- package/{event-handlers/handle-PostEnvAdd.js → src/event-handlers/handle-PostEnvAdd.ts} +4 -7
- package/{event-handlers/handle-PostPull.js → src/event-handlers/handle-PostPull.ts} +4 -7
- package/{index.js → src/index.ts} +6 -10
- package/tsconfig.json +9 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/commands/cloneComponentsFromEnv.js +0 -79
- 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/createUiBuilderComponent.js +0 -85
- package/commands/utils/logger.js +0 -24
- package/commands/utils/mockUiBuilderData.js +0 -149
- package/commands/utils/notifyMissingPackages.js +0 -27
- package/commands/utils/shouldRenderComponents.js +0 -38
- package/commands/version.js +0 -10
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
const aws = require('aws-sdk');
|
|
2
|
-
const logger = require('./utils/logger');
|
|
3
|
-
const { extractArgs } = require('./utils/extractArgs');
|
|
4
|
-
const { listUiBuilderComponents } = require('./utils/syncAmplifyUiBuilderComponents');
|
|
5
|
-
|
|
6
|
-
async function run(context) {
|
|
7
|
-
logger.info('Running create components command in amplify-util-uibuilder');
|
|
8
|
-
const args = extractArgs(context);
|
|
9
|
-
const sourceEnvName = args.sourceEnvName ? args.sourceEnvName : context.exeInfo.sourceEnvName;
|
|
10
|
-
const newEnvName = args.newEnvName ? args.newEnvName : context.exeInfo.localEnvInfo.envName;
|
|
11
|
-
|
|
12
|
-
const existingComponents = await listUiBuilderComponents(context, sourceEnvName);
|
|
13
|
-
if (existingComponents.entities.length === 0) {
|
|
14
|
-
`${existingComponents.entities.length} components exist in source env. Skipping creation of local components.`;
|
|
15
|
-
}
|
|
16
|
-
const existingComponentsNewEnv = await listUiBuilderComponents(context, newEnvName);
|
|
17
|
-
if (existingComponentsNewEnv.entities.length > 0) {
|
|
18
|
-
logger.info(`${existingComponentsNewEnv.entities.length} components already exist in new env. Skipping creation of local components.`);
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
try {
|
|
23
|
-
const environmentName = args.environmentName ? args.environmentName : context.exeInfo.localEnvInfo.envName;
|
|
24
|
-
|
|
25
|
-
const appId = args.appId ? args.appId : context.exeInfo.teamProviderInfo[environmentName].awscloudformation.AmplifyAppId;
|
|
26
|
-
|
|
27
|
-
const awsConfigInfo = await context.amplify.invokePluginMethod(context, 'awscloudformation', undefined, 'loadConfigurationForEnv', [
|
|
28
|
-
context,
|
|
29
|
-
newEnvName,
|
|
30
|
-
appId,
|
|
31
|
-
]);
|
|
32
|
-
|
|
33
|
-
if (process.env.UI_BUILDER_ENDPOINT) {
|
|
34
|
-
awsConfigInfo.endpoint = process.env.UI_BUILDER_ENDPOINT;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (process.env.UI_BUILDER_REGION) {
|
|
38
|
-
awsConfigInfo.region = process.env.UI_BUILDER_REGION;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const amplifyUIBuilder = new aws.AmplifyUIBuilder(awsConfigInfo);
|
|
42
|
-
|
|
43
|
-
const components = existingComponents.entities;
|
|
44
|
-
if (!components.length) {
|
|
45
|
-
logger.info(`No UIBuilder components found in app ${appId} from env ${sourceEnvName}. Skipping component clone process.`);
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
const promises = components.map(async component => {
|
|
49
|
-
return await amplifyUIBuilder
|
|
50
|
-
.createComponent({
|
|
51
|
-
appId,
|
|
52
|
-
environmentName,
|
|
53
|
-
componentToCreate: {
|
|
54
|
-
bindingProperties: component.bindingProperties,
|
|
55
|
-
children: component.children,
|
|
56
|
-
componentType: component.componentType,
|
|
57
|
-
name: component.name,
|
|
58
|
-
overrides: component.overrides,
|
|
59
|
-
properties: component.properties,
|
|
60
|
-
sourceId: component.sourceId,
|
|
61
|
-
variants: component.variants,
|
|
62
|
-
},
|
|
63
|
-
})
|
|
64
|
-
.promise();
|
|
65
|
-
});
|
|
66
|
-
await Promise.all(promises);
|
|
67
|
-
|
|
68
|
-
console.log(
|
|
69
|
-
`Successfully cloned ${components.length} UIBuilder components in app ${appId} from env ${sourceEnvName} to env ${newEnvName}.`,
|
|
70
|
-
);
|
|
71
|
-
} catch (e) {
|
|
72
|
-
logger.warn('This endpoint is broken for now:');
|
|
73
|
-
logger.error(e);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
module.exports = {
|
|
78
|
-
run,
|
|
79
|
-
};
|
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,85 +0,0 @@
|
|
|
1
|
-
const { StudioTemplateRendererManager, StudioTemplateRendererFactory } = require('@aws-amplify/codegen-ui');
|
|
2
|
-
const {
|
|
3
|
-
AmplifyRenderer,
|
|
4
|
-
ReactThemeStudioTemplateRenderer,
|
|
5
|
-
ReactIndexStudioTemplateRenderer,
|
|
6
|
-
ModuleKind,
|
|
7
|
-
ScriptTarget,
|
|
8
|
-
ScriptKind,
|
|
9
|
-
} = require('@aws-amplify/codegen-ui-react');
|
|
10
|
-
const { getUiBuilderComponentsPath } = require('./getUiBuilderComponentsPath');
|
|
11
|
-
const logger = require('./logger');
|
|
12
|
-
const config = process.env.USE_CODEGEN_DEFAULTS
|
|
13
|
-
? {}
|
|
14
|
-
: {
|
|
15
|
-
module: ModuleKind.ESNext,
|
|
16
|
-
target: ScriptTarget.ESNext,
|
|
17
|
-
script: ScriptKind.JSX,
|
|
18
|
-
renderTypeDeclarations: process.env.RENDER_TYPE_DECLARATIONS ? true : false,
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const createUiBuilderComponent = (context, schema) => {
|
|
22
|
-
const uiBuilderComponentsPath = getUiBuilderComponentsPath(context);
|
|
23
|
-
const rendererFactory = new StudioTemplateRendererFactory(component => new AmplifyRenderer(component, config));
|
|
24
|
-
|
|
25
|
-
const outputPathDir = uiBuilderComponentsPath;
|
|
26
|
-
const outputConfig = {
|
|
27
|
-
outputPathDir,
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const rendererManager = new StudioTemplateRendererManager(rendererFactory, outputConfig);
|
|
31
|
-
|
|
32
|
-
rendererManager.renderSchemaToTemplate(schema);
|
|
33
|
-
return schema;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const createUiBuilderTheme = (context, schema) => {
|
|
37
|
-
const uiBuilderComponentsPath = getUiBuilderComponentsPath(context);
|
|
38
|
-
const rendererFactory = new StudioTemplateRendererFactory(
|
|
39
|
-
component => new ReactThemeStudioTemplateRenderer(component, config),
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
const outputPathDir = uiBuilderComponentsPath;
|
|
43
|
-
const outputConfig = {
|
|
44
|
-
outputPathDir,
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const rendererManager = new StudioTemplateRendererManager(rendererFactory, outputConfig);
|
|
48
|
-
|
|
49
|
-
try {
|
|
50
|
-
rendererManager.renderSchemaToTemplate(schema);
|
|
51
|
-
return schema;
|
|
52
|
-
} catch (e) {
|
|
53
|
-
logger.error(e);
|
|
54
|
-
logger.info({ msg: 'Skipping invalid theme with schema', schema: JSON.stringify(schema, null, 2) });
|
|
55
|
-
throw e;
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const generateAmplifyUiBuilderIndexFile = (context, schemas) => {
|
|
60
|
-
const uiBuilderComponentsPath = getUiBuilderComponentsPath(context);
|
|
61
|
-
const rendererFactory = new StudioTemplateRendererFactory(
|
|
62
|
-
component => new ReactIndexStudioTemplateRenderer(component, config),
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
const outputPathDir = uiBuilderComponentsPath;
|
|
66
|
-
const outputConfig = {
|
|
67
|
-
outputPathDir,
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const rendererManager = new StudioTemplateRendererManager(rendererFactory, outputConfig);
|
|
71
|
-
|
|
72
|
-
try {
|
|
73
|
-
rendererManager.renderSchemaToTemplate(schemas);
|
|
74
|
-
} catch (e) {
|
|
75
|
-
logger.error(e);
|
|
76
|
-
logger.info({ msg: 'Failed to generate component index file' });
|
|
77
|
-
throw e;
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
module.exports = {
|
|
82
|
-
createUiBuilderComponent,
|
|
83
|
-
createUiBuilderTheme,
|
|
84
|
-
generateAmplifyUiBuilderIndexFile,
|
|
85
|
-
};
|
package/commands/utils/logger.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
const log = (message, level = 'log') => {
|
|
2
|
-
if (process.env.VERBOSE_LOGGING) {
|
|
3
|
-
console[level](message);
|
|
4
|
-
}
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
const error = message => {
|
|
8
|
-
log(message, 'error');
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const warn = message => {
|
|
12
|
-
log(message, 'warn');
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const info = message => {
|
|
16
|
-
log(message, 'info');
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
module.exports = {
|
|
20
|
-
log,
|
|
21
|
-
error,
|
|
22
|
-
warn,
|
|
23
|
-
info,
|
|
24
|
-
};
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
// This file provides mocks for manual testing
|
|
2
|
-
const mockUiBuilderComponents = {
|
|
3
|
-
entities: [
|
|
4
|
-
{
|
|
5
|
-
appId: 'd2o18y21obnmoz',
|
|
6
|
-
bindingProperties: {},
|
|
7
|
-
children: [
|
|
8
|
-
{
|
|
9
|
-
children: [],
|
|
10
|
-
componentType: 'Box',
|
|
11
|
-
properties: {
|
|
12
|
-
width: {
|
|
13
|
-
value: '133px',
|
|
14
|
-
},
|
|
15
|
-
padding: {
|
|
16
|
-
value: '0px 0px 0px 0px',
|
|
17
|
-
},
|
|
18
|
-
backgroundColor: {
|
|
19
|
-
value: 'rgb(255,255,255)',
|
|
20
|
-
},
|
|
21
|
-
height: {
|
|
22
|
-
value: '55px',
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
],
|
|
27
|
-
componentType: 'Box',
|
|
28
|
-
environmentName: 'staging',
|
|
29
|
-
id: 'c-65Dz5ryFZKFnfNj8Si',
|
|
30
|
-
name: 'Frame1',
|
|
31
|
-
overrides: {},
|
|
32
|
-
properties: {
|
|
33
|
-
width: {
|
|
34
|
-
value: '291px',
|
|
35
|
-
},
|
|
36
|
-
padding: {
|
|
37
|
-
value: '0px 0px 0px 0px',
|
|
38
|
-
},
|
|
39
|
-
backgroundColor: {
|
|
40
|
-
value: 'rgb(255,255,0)',
|
|
41
|
-
},
|
|
42
|
-
height: {
|
|
43
|
-
value: '158px',
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
variants: [],
|
|
47
|
-
},
|
|
48
|
-
],
|
|
49
|
-
nextToken: '',
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const mockUiBuilderThemes = {
|
|
53
|
-
entities: [
|
|
54
|
-
{
|
|
55
|
-
id: '1234-5678-9010',
|
|
56
|
-
name: 'MyTheme',
|
|
57
|
-
values: [
|
|
58
|
-
{
|
|
59
|
-
key: 'tokens',
|
|
60
|
-
value: {
|
|
61
|
-
children: [
|
|
62
|
-
{
|
|
63
|
-
key: 'colors',
|
|
64
|
-
value: {
|
|
65
|
-
children: [
|
|
66
|
-
{
|
|
67
|
-
key: 'font',
|
|
68
|
-
value: {
|
|
69
|
-
children: [
|
|
70
|
-
{
|
|
71
|
-
key: 'primary',
|
|
72
|
-
value: {
|
|
73
|
-
children: [
|
|
74
|
-
{
|
|
75
|
-
key: 'value',
|
|
76
|
-
value: {
|
|
77
|
-
value: '#008080',
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
],
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
],
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
],
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
],
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
],
|
|
93
|
-
overrides: [
|
|
94
|
-
{
|
|
95
|
-
key: 'colorMode',
|
|
96
|
-
value: {
|
|
97
|
-
value: 'dark',
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
key: 'tokens',
|
|
102
|
-
value: {
|
|
103
|
-
children: [
|
|
104
|
-
{
|
|
105
|
-
key: 'colors',
|
|
106
|
-
value: {
|
|
107
|
-
children: [
|
|
108
|
-
{
|
|
109
|
-
key: 'black',
|
|
110
|
-
value: {
|
|
111
|
-
children: [
|
|
112
|
-
{
|
|
113
|
-
key: 'value',
|
|
114
|
-
value: {
|
|
115
|
-
value: '#fff',
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
],
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
key: 'white',
|
|
123
|
-
value: {
|
|
124
|
-
children: [
|
|
125
|
-
{
|
|
126
|
-
key: 'value',
|
|
127
|
-
value: {
|
|
128
|
-
value: '#000',
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
],
|
|
132
|
-
},
|
|
133
|
-
},
|
|
134
|
-
],
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
],
|
|
138
|
-
},
|
|
139
|
-
},
|
|
140
|
-
],
|
|
141
|
-
},
|
|
142
|
-
],
|
|
143
|
-
nextToken: '',
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
module.exports = {
|
|
147
|
-
mockUiBuilderComponents,
|
|
148
|
-
mockUiBuilderThemes,
|
|
149
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
const fs = require('fs-extra');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const { extractArgs } = require('./extractArgs');
|
|
4
|
-
const REQUIRED_PACKAGES = ['@aws-amplify/ui-react', 'aws-amplify'];
|
|
5
|
-
|
|
6
|
-
const notifyMissingPackages = context => {
|
|
7
|
-
const args = extractArgs(context);
|
|
8
|
-
const localEnvFilePath = args.localEnvFilePath ? args.localEnvFilePath : context.amplify._pathManager.getLocalEnvFilePath();
|
|
9
|
-
const localEnvJson = JSON.parse(fs.readFileSync(localEnvFilePath).toString());
|
|
10
|
-
const packageJsonPath = path.join(localEnvJson.projectPath, 'package.json');
|
|
11
|
-
if (!fs.existsSync(packageJsonPath)) {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath).toString());
|
|
15
|
-
REQUIRED_PACKAGES.forEach(packageName => {
|
|
16
|
-
const packageIsInstalled = Object.keys(packageJson.dependencies).includes(packageName);
|
|
17
|
-
if (!packageIsInstalled) {
|
|
18
|
-
console.warn(
|
|
19
|
-
`UIBuilder components required "${packageName}" that is not in your package.json. Please run \`npm install ${packageName}\``,
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
module.exports = {
|
|
26
|
-
notifyMissingPackages,
|
|
27
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
const logger = require('./logger');
|
|
2
|
-
|
|
3
|
-
async function shouldRenderComponents(context) {
|
|
4
|
-
if (process.env.FORCE_RENDER) {
|
|
5
|
-
logger.info('Forcing component render since environment variable flag is set.');
|
|
6
|
-
return true;
|
|
7
|
-
}
|
|
8
|
-
if (context.input.options && context.input.options['no-codegen']) {
|
|
9
|
-
logger.warn('Not pulling components because --no-codegen flag is set');
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
if (!context.exeInfo || !context.exeInfo.projectConfig) {
|
|
14
|
-
logger.warn('Not pulling components because there is no projectConfig set for this project');
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if (!context.exeInfo.projectConfig.providers.includes('awscloudformation')) {
|
|
19
|
-
logger.warn('Not pulling components because there is no "awscloudformation" provider');
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (context.exeInfo.projectConfig.frontend !== 'javascript') {
|
|
24
|
-
logger.warn('Not pulling components because this project is not configured as a javascript frontend');
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (context.exeInfo.projectConfig['javascript'].framework !== 'react') {
|
|
29
|
-
logger.warn('Not pulling components because this project is not configured with the "react" framework');
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
module.exports = {
|
|
37
|
-
shouldRenderComponents,
|
|
38
|
-
};
|