@aws-amplify/amplify-util-uibuilder 1.7.0 → 1.8.0-ym-tagged-release.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/API.md +1 -1
- package/CHANGELOG.md +20 -0
- package/lib/clients/amplify-studio-client.d.ts +1 -1
- package/lib/clients/amplify-studio-client.d.ts.map +1 -1
- package/lib/clients/amplify-studio-client.js +1 -1
- package/lib/clients/amplify-studio-client.js.map +1 -1
- package/lib/commands/cloneComponentsFromEnv.d.ts +1 -1
- package/lib/commands/cloneComponentsFromEnv.d.ts.map +1 -1
- package/lib/commands/generateComponents.d.ts +1 -1
- package/lib/commands/generateComponents.d.ts.map +1 -1
- package/lib/commands/generateComponents.js +5 -1
- package/lib/commands/generateComponents.js.map +1 -1
- package/lib/commands/utils/codegenResources.d.ts +1 -1
- package/lib/commands/utils/codegenResources.d.ts.map +1 -1
- package/lib/commands/utils/environmentHelpers.d.ts +1 -1
- package/lib/commands/utils/environmentHelpers.d.ts.map +1 -1
- package/lib/commands/utils/environmentHelpers.js +1 -1
- package/lib/commands/utils/environmentHelpers.js.map +1 -1
- package/lib/commands/utils/extractArgs.d.ts +1 -1
- package/lib/commands/utils/extractArgs.d.ts.map +1 -1
- package/lib/commands/utils/featureFlags.js +1 -1
- package/lib/commands/utils/featureFlags.js.map +1 -1
- package/lib/commands/utils/getUiBuilderComponentsPath.d.ts +1 -1
- package/lib/commands/utils/getUiBuilderComponentsPath.d.ts.map +1 -1
- package/lib/commands/utils/index.d.ts +1 -0
- package/lib/commands/utils/index.d.ts.map +1 -1
- package/lib/commands/utils/index.js +1 -0
- package/lib/commands/utils/index.js.map +1 -1
- package/lib/commands/utils/notifyMissingPackages.d.ts +2 -2
- package/lib/commands/utils/notifyMissingPackages.d.ts.map +1 -1
- package/lib/commands/utils/notifyMissingPackages.js +4 -4
- package/lib/commands/utils/notifyMissingPackages.js.map +1 -1
- package/lib/commands/utils/shouldRenderComponents.d.ts +1 -1
- package/lib/commands/utils/shouldRenderComponents.d.ts.map +1 -1
- package/lib/commands/utils/shouldRenderComponents.js +1 -1
- package/lib/commands/utils/shouldRenderComponents.js.map +1 -1
- package/lib/commands/utils/storageManager.d.ts +5 -0
- package/lib/commands/utils/storageManager.d.ts.map +1 -0
- package/lib/commands/utils/storageManager.js +20 -0
- package/lib/commands/utils/storageManager.js.map +1 -0
- package/lib/commands/utils/syncAmplifyUiBuilderComponents.d.ts +1 -1
- package/lib/commands/utils/syncAmplifyUiBuilderComponents.d.ts.map +1 -1
- package/lib/event-handlers/handle-PostEnvAdd.d.ts +1 -1
- package/lib/event-handlers/handle-PostEnvAdd.d.ts.map +1 -1
- package/lib/event-handlers/handle-PostPull.d.ts +1 -1
- package/lib/event-handlers/handle-PostPull.d.ts.map +1 -1
- package/lib/event-handlers/handle-PostPush.d.ts +1 -1
- package/lib/event-handlers/handle-PostPush.d.ts.map +1 -1
- package/lib/event-handlers/handle-PrePush.d.ts +1 -1
- package/lib/event-handlers/handle-PrePush.d.ts.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/utils/prePushHandler.d.ts +1 -1
- package/lib/utils/prePushHandler.d.ts.map +1 -1
- package/package.json +26 -19
- package/src/__tests__/cloneComponentsFromEnv.test.ts +1 -1
- package/src/__tests__/generateComponents.test.ts +1 -1
- package/src/__tests__/getAmplifyDataSchema.test.ts +1 -2
- package/src/__tests__/help.test.ts +1 -1
- package/src/__tests__/notifyMissingPackages.test.ts +19 -7
- package/src/__tests__/prePushHandler.test.ts +2 -2
- package/src/__tests__/shouldRenderComponents.test.ts +6 -6
- package/src/__tests__/storageManager.test.ts +42 -0
- package/src/__tests__/syncAmplifyUiComponents.test.ts +3 -3
- package/src/__tests__/version.test.ts +1 -1
- package/src/clients/amplify-studio-client.ts +1 -1
- package/src/commands/cloneComponentsFromEnv.ts +1 -1
- package/src/commands/generateComponents.ts +9 -2
- package/src/commands/utils/codegenResources.ts +1 -1
- package/src/commands/utils/environmentHelpers.ts +1 -1
- package/src/commands/utils/extractArgs.ts +1 -1
- package/src/commands/utils/featureFlags.ts +1 -1
- package/src/commands/utils/getUiBuilderComponentsPath.ts +1 -1
- package/src/commands/utils/index.ts +1 -0
- package/src/commands/utils/notifyMissingPackages.ts +5 -4
- package/src/commands/utils/shouldRenderComponents.ts +1 -1
- package/src/commands/utils/storageManager.ts +17 -0
- package/src/commands/utils/syncAmplifyUiBuilderComponents.ts +1 -1
- package/src/event-handlers/handle-PostEnvAdd.ts +1 -1
- package/src/event-handlers/handle-PostPull.ts +1 -1
- package/src/event-handlers/handle-PostPush.ts +1 -1
- package/src/event-handlers/handle-PrePush.ts +1 -1
- package/src/index.ts +1 -1
- package/src/utils/prePushHandler.ts +1 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -9,7 +9,7 @@ jest.mock('../commands/utils/featureFlags', () => ({
|
|
|
9
9
|
getTransformerVersion: jest.fn().mockReturnValue(2),
|
|
10
10
|
}));
|
|
11
11
|
jest.mock('../commands/utils/extractArgs');
|
|
12
|
-
jest.mock('amplify-cli-core');
|
|
12
|
+
jest.mock('@aws-amplify/amplify-cli-core');
|
|
13
13
|
|
|
14
14
|
const mockedComponentExport = jest.fn((envName: string) => {
|
|
15
15
|
if (envName === 'newEnvName') {
|
|
@@ -3,7 +3,7 @@ import * as utils from '../commands/utils';
|
|
|
3
3
|
import { run } from '../commands/generateComponents';
|
|
4
4
|
|
|
5
5
|
jest.mock('../commands/utils');
|
|
6
|
-
jest.mock('amplify-cli-core');
|
|
6
|
+
jest.mock('@aws-amplify/amplify-cli-core');
|
|
7
7
|
const awsMock = aws as any;
|
|
8
8
|
const utilsMock = utils as any;
|
|
9
9
|
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { printer } from '@aws-amplify/amplify-prompts'; // eslint-disable-line import/no-extraneous-dependencies
|
|
2
|
-
import { mocked } from 'ts-jest/utils';
|
|
3
2
|
import { getAmplifyDataSchema } from '../commands/utils';
|
|
4
3
|
|
|
5
4
|
jest.mock('@aws-amplify/amplify-prompts');
|
|
6
5
|
|
|
7
|
-
const printerMock = mocked(printer);
|
|
6
|
+
const printerMock = jest.mocked(printer);
|
|
8
7
|
|
|
9
8
|
const sampleIntrospectionSchema = {
|
|
10
9
|
version: 1,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as printerDependency from '@aws-amplify/amplify-prompts';
|
|
2
|
-
import * as JSONUtilitiesDependency from 'amplify-cli-core';
|
|
2
|
+
import * as JSONUtilitiesDependency from '@aws-amplify/amplify-cli-core';
|
|
3
3
|
import { notifyMissingPackages } from '../commands/utils/notifyMissingPackages';
|
|
4
|
-
import { $TSContext } from 'amplify-cli-core';
|
|
5
|
-
jest.mock('amplify-prompts');
|
|
6
|
-
jest.mock('amplify-cli-core');
|
|
4
|
+
import { $TSContext } from '@aws-amplify/amplify-cli-core';
|
|
5
|
+
jest.mock('@aws-amplify/amplify-prompts');
|
|
6
|
+
jest.mock('@aws-amplify/amplify-cli-core');
|
|
7
7
|
printerDependency.printer.info = jest.fn();
|
|
8
8
|
printerDependency.printer.debug = jest.fn();
|
|
9
9
|
printerDependency.printer.warn = jest.fn();
|
|
@@ -24,7 +24,7 @@ describe('should notify when packages are missing', () => {
|
|
|
24
24
|
},
|
|
25
25
|
},
|
|
26
26
|
};
|
|
27
|
-
notifyMissingPackages(context as unknown as $TSContext);
|
|
27
|
+
notifyMissingPackages(context as unknown as $TSContext, false);
|
|
28
28
|
expect(printerDependency.printer.debug).toBeCalledTimes(1);
|
|
29
29
|
});
|
|
30
30
|
|
|
@@ -40,7 +40,7 @@ describe('should notify when packages are missing', () => {
|
|
|
40
40
|
},
|
|
41
41
|
},
|
|
42
42
|
};
|
|
43
|
-
notifyMissingPackages(context as unknown as $TSContext);
|
|
43
|
+
notifyMissingPackages(context as unknown as $TSContext, false);
|
|
44
44
|
expect(printerDependency.printer.debug).toBeCalledTimes(1);
|
|
45
45
|
});
|
|
46
46
|
|
|
@@ -52,7 +52,7 @@ describe('should notify when packages are missing', () => {
|
|
|
52
52
|
},
|
|
53
53
|
},
|
|
54
54
|
};
|
|
55
|
-
notifyMissingPackages(context as unknown as $TSContext);
|
|
55
|
+
notifyMissingPackages(context as unknown as $TSContext, true);
|
|
56
56
|
expect(printerDependency.printer.warn).toBeCalledTimes(3);
|
|
57
57
|
});
|
|
58
58
|
|
|
@@ -69,6 +69,18 @@ describe('should notify when packages are missing', () => {
|
|
|
69
69
|
},
|
|
70
70
|
};
|
|
71
71
|
notifyMissingPackages(context as unknown as $TSContext);
|
|
72
|
+
expect(printerDependency.printer.warn).toBeCalledTimes(1);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('notifies for all dependencies except storage if user is not using StorageManager', () => {
|
|
76
|
+
const context = {
|
|
77
|
+
input: {
|
|
78
|
+
options: {
|
|
79
|
+
localEnvFilePath: __dirname + '/mock.json',
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
notifyMissingPackages(context as unknown as $TSContext, false);
|
|
72
84
|
expect(printerDependency.printer.warn).toBeCalledTimes(2);
|
|
73
85
|
});
|
|
74
86
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// aws-sdk, amplify-cli-core, amplify-prompts are in package dependencies
|
|
1
|
+
// aws-sdk, @aws-amplify/amplify-cli-core, amplify-prompts are in package dependencies
|
|
2
2
|
import aws from 'aws-sdk'; // eslint-disable-line import/no-extraneous-dependencies
|
|
3
3
|
import { Form } from 'aws-sdk/clients/amplifyuibuilder'; // eslint-disable-line import/no-extraneous-dependencies
|
|
4
4
|
import { printer } from '@aws-amplify/amplify-prompts'; // eslint-disable-line import/no-extraneous-dependencies
|
|
@@ -6,7 +6,7 @@ import * as utils from '../commands/utils';
|
|
|
6
6
|
import { prePushHandler } from '../utils/prePushHandler';
|
|
7
7
|
|
|
8
8
|
jest.mock('../commands/utils');
|
|
9
|
-
jest.mock('amplify-cli-core');
|
|
9
|
+
jest.mock('@aws-amplify/amplify-cli-core');
|
|
10
10
|
jest.mock('../commands/utils/featureFlags', () => ({
|
|
11
11
|
getTransformerVersion: jest.fn().mockImplementation(() => 2),
|
|
12
12
|
}));
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
|
-
import { $TSContext } from 'amplify-cli-core';
|
|
2
|
+
import { $TSContext } from '@aws-amplify/amplify-cli-core';
|
|
3
3
|
import aws from 'aws-sdk'; // eslint-disable-line import/no-extraneous-dependencies
|
|
4
4
|
import { shouldRenderComponents } from '../commands/utils/shouldRenderComponents';
|
|
5
5
|
|
|
6
6
|
const awsMock = aws as any;
|
|
7
7
|
|
|
8
|
-
jest.mock('amplify-cli-core', () => ({
|
|
9
|
-
...jest.requireActual('amplify-cli-core'),
|
|
8
|
+
jest.mock('@aws-amplify/amplify-cli-core', () => ({
|
|
9
|
+
...jest.requireActual('@aws-amplify/amplify-cli-core'),
|
|
10
10
|
stateManager: {
|
|
11
11
|
getProjectConfig: jest.fn().mockReturnValue({
|
|
12
12
|
providers: ['awscloudformation'],
|
|
@@ -66,7 +66,7 @@ describe('should render components', () => {
|
|
|
66
66
|
});
|
|
67
67
|
|
|
68
68
|
it("doesn't work if provider is not awscloudformation", async () => {
|
|
69
|
-
jest.mock('amplify-cli-core', () => ({
|
|
69
|
+
jest.mock('@aws-amplify/amplify-cli-core', () => ({
|
|
70
70
|
stateManager: {
|
|
71
71
|
getProjectConfig: jest.fn().mockReturnValue({
|
|
72
72
|
providers: [],
|
|
@@ -82,7 +82,7 @@ describe('should render components', () => {
|
|
|
82
82
|
});
|
|
83
83
|
|
|
84
84
|
it('should return false if frontend is ios', async () => {
|
|
85
|
-
jest.mock('amplify-cli-core', () => ({
|
|
85
|
+
jest.mock('@aws-amplify/amplify-cli-core', () => ({
|
|
86
86
|
stateManager: {
|
|
87
87
|
getProjectConfig: jest.fn().mockReturnValue({
|
|
88
88
|
providers: [],
|
|
@@ -95,7 +95,7 @@ describe('should render components', () => {
|
|
|
95
95
|
});
|
|
96
96
|
|
|
97
97
|
it('should return false if frontend is vue', async () => {
|
|
98
|
-
jest.mock('amplify-cli-core', () => ({
|
|
98
|
+
jest.mock('@aws-amplify/amplify-cli-core', () => ({
|
|
99
99
|
stateManager: {
|
|
100
100
|
getProjectConfig: jest.fn().mockReturnValue({
|
|
101
101
|
providers: [],
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { StudioSchema } from '@aws-amplify/codegen-ui';
|
|
2
|
+
import { hasStorageField } from '../commands/utils';
|
|
3
|
+
|
|
4
|
+
const formWithNoCustomization: StudioSchema = {
|
|
5
|
+
id: 'f-123456',
|
|
6
|
+
name: 'BlogCreateForm',
|
|
7
|
+
formActionType: 'create',
|
|
8
|
+
dataType: {
|
|
9
|
+
dataSourceType: 'DataStore',
|
|
10
|
+
dataTypeName: 'Blog',
|
|
11
|
+
},
|
|
12
|
+
fields: {},
|
|
13
|
+
sectionalElements: {},
|
|
14
|
+
style: {},
|
|
15
|
+
cta: {},
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const formWithNoStorageField: StudioSchema = {
|
|
19
|
+
...formWithNoCustomization,
|
|
20
|
+
dataType: { dataSourceType: 'Custom', dataTypeName: 'Blog' },
|
|
21
|
+
fields: {
|
|
22
|
+
name: { inputType: { type: 'TextField' } },
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const formWithStorageField: StudioSchema = {
|
|
27
|
+
...formWithNoCustomization,
|
|
28
|
+
dataType: { dataSourceType: 'Custom', dataTypeName: 'Blog' },
|
|
29
|
+
fields: {
|
|
30
|
+
name: { inputType: { type: 'StorageField' } },
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
describe('hasStorageManager', () => {
|
|
35
|
+
it('should return false for form with no StorageManager config', () => {
|
|
36
|
+
expect(hasStorageField(formWithNoStorageField)).toBe(false);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('should return true for form with StorageManager config', () => {
|
|
40
|
+
expect(hasStorageField(formWithStorageField)).toBe(true);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable spellcheck/spell-checker */
|
|
2
|
-
import { AmplifyCategories, AmplifySupportedService, stateManager } from 'amplify-cli-core'; // eslint-disable-line import/no-extraneous-dependencies
|
|
2
|
+
import { AmplifyCategories, AmplifySupportedService, stateManager } from '@aws-amplify/amplify-cli-core'; // eslint-disable-line import/no-extraneous-dependencies
|
|
3
3
|
import aws from 'aws-sdk'; // eslint-disable-line import/no-extraneous-dependencies
|
|
4
4
|
import {
|
|
5
5
|
generateUiBuilderComponents,
|
|
@@ -13,8 +13,8 @@ import { AmplifyStudioClient } from '../clients';
|
|
|
13
13
|
import * as createUiBuilderComponentDependency from '../commands/utils/codegenResources';
|
|
14
14
|
import { exampleSchema } from './utils';
|
|
15
15
|
|
|
16
|
-
jest.mock('amplify-cli-core', () => ({
|
|
17
|
-
...jest.requireActual('amplify-cli-core'),
|
|
16
|
+
jest.mock('@aws-amplify/amplify-cli-core', () => ({
|
|
17
|
+
...jest.requireActual('@aws-amplify/amplify-cli-core'),
|
|
18
18
|
FeatureFlags: {
|
|
19
19
|
getBoolean: () => false,
|
|
20
20
|
getNumber: () => 0,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { printer } from '@aws-amplify/amplify-prompts';
|
|
2
2
|
import { run } from '../commands/version';
|
|
3
|
-
jest.mock('amplify-prompts');
|
|
3
|
+
jest.mock('@aws-amplify/amplify-prompts');
|
|
4
4
|
printer.info = jest.fn();
|
|
5
5
|
describe('can run version script', () => {
|
|
6
6
|
it('runs version script', async () => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $TSContext, CloudformationProviderFacade } from 'amplify-cli-core';
|
|
1
|
+
import { $TSContext, CloudformationProviderFacade } from '@aws-amplify/amplify-cli-core';
|
|
2
2
|
import type { ServiceConfigurationOptions } from 'aws-sdk/lib/service';
|
|
3
3
|
import type { CreateComponentData, Component, Theme, Form } from 'aws-sdk/clients/amplifyuibuilder';
|
|
4
4
|
import { AmplifyUIBuilder, AmplifyBackend } from 'aws-sdk';
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { StudioSchema } from '@aws-amplify/codegen-ui';
|
|
3
3
|
import ora from 'ora';
|
|
4
4
|
import { printer } from '@aws-amplify/amplify-prompts';
|
|
5
|
-
import { $TSContext } from 'amplify-cli-core';
|
|
5
|
+
import { $TSContext } from '@aws-amplify/amplify-cli-core';
|
|
6
6
|
import { AmplifyStudioClient } from '../clients';
|
|
7
7
|
import {
|
|
8
8
|
notifyMissingPackages,
|
|
@@ -16,6 +16,8 @@ import {
|
|
|
16
16
|
isStudioForm,
|
|
17
17
|
isFormDetachedFromModel,
|
|
18
18
|
deleteDetachedForms,
|
|
19
|
+
hasStorageField,
|
|
20
|
+
isFormSchema,
|
|
19
21
|
} from './utils';
|
|
20
22
|
|
|
21
23
|
/**
|
|
@@ -60,6 +62,7 @@ export const run = async (context: $TSContext, eventType: 'PostPush' | 'PostPull
|
|
|
60
62
|
let hasSuccessfulForm = false;
|
|
61
63
|
const failedResponseNames: string[] = [];
|
|
62
64
|
const modelNames = dataSchema?.models ? new Set(Object.keys(dataSchema.models)) : new Set<string>();
|
|
65
|
+
let hasStorageManagerField = false;
|
|
63
66
|
|
|
64
67
|
Object.entries(generatedResults).forEach(([key, results]) => {
|
|
65
68
|
results.forEach((result) => {
|
|
@@ -67,6 +70,10 @@ export const run = async (context: $TSContext, eventType: 'PostPush' | 'PostPull
|
|
|
67
70
|
successfulSchemas.push(result.schema);
|
|
68
71
|
if (key === 'form') {
|
|
69
72
|
hasSuccessfulForm = true;
|
|
73
|
+
|
|
74
|
+
if (!hasStorageManagerField && isFormSchema(result.schema) && hasStorageField(result.schema)) {
|
|
75
|
+
hasStorageManagerField = true;
|
|
76
|
+
}
|
|
70
77
|
}
|
|
71
78
|
} else {
|
|
72
79
|
const failedSchema = result.schema;
|
|
@@ -112,7 +119,7 @@ export const run = async (context: $TSContext, eventType: 'PostPush' | 'PostPull
|
|
|
112
119
|
);
|
|
113
120
|
}
|
|
114
121
|
|
|
115
|
-
notifyMissingPackages(context);
|
|
122
|
+
notifyMissingPackages(context, hasStorageManagerField);
|
|
116
123
|
|
|
117
124
|
await deleteDetachedForms(detachedForms, studioClient);
|
|
118
125
|
} catch (e) {
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
ReactThemeStudioTemplateRendererOptions,
|
|
28
28
|
} from '@aws-amplify/codegen-ui-react';
|
|
29
29
|
import { printer } from '@aws-amplify/amplify-prompts';
|
|
30
|
-
import { $TSContext } from 'amplify-cli-core';
|
|
30
|
+
import { $TSContext } from '@aws-amplify/amplify-cli-core';
|
|
31
31
|
import { getUiBuilderComponentsPath } from './getUiBuilderComponentsPath';
|
|
32
32
|
import { ModelIntrospectionSchema } from '@aws-amplify/appsync-modelgen-plugin';
|
|
33
33
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable spellcheck/spell-checker */
|
|
2
|
-
import { FeatureFlags, pathManager, stateManager } from 'amplify-cli-core';
|
|
2
|
+
import { FeatureFlags, pathManager, stateManager } from '@aws-amplify/amplify-cli-core';
|
|
3
3
|
import { printer } from '@aws-amplify/amplify-prompts';
|
|
4
4
|
|
|
5
5
|
// This is copy-pasta from the category api until they can expose the method to plugins
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { pathManager, JSONUtilities, $TSContext, $TSAny } from 'amplify-cli-core';
|
|
1
|
+
import { pathManager, JSONUtilities, $TSContext, $TSAny } from '@aws-amplify/amplify-cli-core';
|
|
2
2
|
import { printer } from '@aws-amplify/amplify-prompts';
|
|
3
3
|
import fs from 'fs-extra';
|
|
4
4
|
import path from 'path';
|
|
@@ -7,13 +7,14 @@ import { RequiredDependency } from '@aws-amplify/codegen-ui';
|
|
|
7
7
|
import { ReactRequiredDependencyProvider } from '@aws-amplify/codegen-ui-react';
|
|
8
8
|
import { extractArgs } from './extractArgs';
|
|
9
9
|
|
|
10
|
-
const getRequiredDependencies = (): RequiredDependency[] =>
|
|
10
|
+
const getRequiredDependencies = (hasStorageManagerField?: boolean): RequiredDependency[] =>
|
|
11
|
+
new ReactRequiredDependencyProvider().getRequiredDependencies(hasStorageManagerField);
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Displays a warning to the user if they have npm dependencies
|
|
14
15
|
* they need to install in their application for UIBuilder components to work properly
|
|
15
16
|
*/
|
|
16
|
-
export const notifyMissingPackages = (context: $TSContext): void => {
|
|
17
|
+
export const notifyMissingPackages = (context: $TSContext, hasStorageManagerField?: boolean): void => {
|
|
17
18
|
const args = extractArgs(context);
|
|
18
19
|
const localEnvFilePath = args.localEnvFilePath ?? pathManager.getLocalEnvFilePath();
|
|
19
20
|
if (!fs.existsSync(localEnvFilePath)) {
|
|
@@ -27,7 +28,7 @@ export const notifyMissingPackages = (context: $TSContext): void => {
|
|
|
27
28
|
return;
|
|
28
29
|
}
|
|
29
30
|
const packageJson = JSONUtilities.readJson(packageJsonPath) as { dependencies: { [key: string]: string } };
|
|
30
|
-
getRequiredDependencies().forEach((dependency: $TSAny) => {
|
|
31
|
+
getRequiredDependencies(hasStorageManagerField).forEach((dependency: $TSAny) => {
|
|
31
32
|
const packageIsInstalled = Object.keys(packageJson.dependencies).includes(dependency.dependencyName);
|
|
32
33
|
if (!packageIsInstalled) {
|
|
33
34
|
printer.warn(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable prefer-arrow/prefer-arrow-functions */
|
|
2
|
-
import { $TSContext, stateManager } from 'amplify-cli-core';
|
|
2
|
+
import { $TSContext, stateManager } from '@aws-amplify/amplify-cli-core';
|
|
3
3
|
import { printer } from '@aws-amplify/amplify-prompts';
|
|
4
4
|
import { AmplifyStudioClient } from '../../clients';
|
|
5
5
|
import { getAppId } from './environmentHelpers';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { StudioForm, StudioFormFieldConfig, StudioGenericFieldConfig, StudioSchema } from '@aws-amplify/codegen-ui';
|
|
2
|
+
|
|
3
|
+
export const hasStorageField = (form: StudioForm): boolean => {
|
|
4
|
+
const result = Object.values(form.fields).some((field) => {
|
|
5
|
+
return isGenericFieldConfig(field) && field.inputType?.type === 'StorageField';
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
return result;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const isFormSchema = (schema: StudioSchema): schema is StudioForm => {
|
|
12
|
+
return schema && Object.keys(schema).includes('fields');
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const isGenericFieldConfig = (config: StudioFormFieldConfig): config is StudioGenericFieldConfig => {
|
|
16
|
+
return !Object.keys(config).includes('excluded');
|
|
17
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $TSContext } from 'amplify-cli-core';
|
|
1
|
+
import { $TSContext } from '@aws-amplify/amplify-cli-core';
|
|
2
2
|
import { printer } from '@aws-amplify/amplify-prompts';
|
|
3
3
|
import AmplifyUIBuilder from 'aws-sdk/clients/amplifyuibuilder';
|
|
4
4
|
import { AmplifyStudioClient } from '../clients';
|