@aws-amplify/amplify-util-uibuilder 1.2.13 → 1.2.15-beta.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 +19 -0
- package/lib/commands/generateComponents.d.ts.map +1 -1
- package/lib/commands/generateComponents.js +4 -1
- package/lib/commands/generateComponents.js.map +1 -1
- package/lib/commands/utils/createUiBuilderComponent.d.ts +5 -3
- package/lib/commands/utils/createUiBuilderComponent.d.ts.map +1 -1
- package/lib/commands/utils/createUiBuilderComponent.js +22 -17
- package/lib/commands/utils/createUiBuilderComponent.js.map +1 -1
- package/lib/commands/utils/createUiBuilderComponentNew.d.ts +5 -0
- package/lib/commands/utils/createUiBuilderComponentNew.d.ts.map +1 -0
- package/lib/commands/utils/createUiBuilderComponentNew.js +44 -0
- package/lib/commands/utils/createUiBuilderComponentNew.js.map +1 -0
- package/lib/commands/utils/notifyMissingPackages.d.ts +2 -1
- package/lib/commands/utils/notifyMissingPackages.d.ts.map +1 -1
- package/lib/commands/utils/notifyMissingPackages.js +18 -13
- package/lib/commands/utils/notifyMissingPackages.js.map +1 -1
- package/lib/commands/utils/syncAmplifyUiBuilderComponents.d.ts +2 -2
- package/package.json +12 -7
- package/src/__tests__/createUiBuilderComponent.test.ts +2 -2
- package/src/__tests__/notifyMissingPackages.test.ts +5 -5
- package/src/commands/generateComponents.ts +7 -3
- package/src/commands/utils/createUiBuilderComponent.ts +37 -23
- package/src/commands/utils/createUiBuilderComponentNew.ts +53 -0
- package/src/commands/utils/notifyMissingPackages.ts +27 -15
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -2,10 +2,24 @@ import { pathManager, JSONUtilities, $TSContext, $TSAny } from 'amplify-cli-core
|
|
|
2
2
|
import { printer } from 'amplify-prompts';
|
|
3
3
|
import fs from 'fs-extra';
|
|
4
4
|
import path from 'path';
|
|
5
|
+
import rangeSubset from 'semver/ranges/subset';
|
|
5
6
|
import { extractArgs } from './extractArgs';
|
|
6
|
-
|
|
7
|
+
import { ReactRequiredDependencyProvider } from '@aws-amplify/codegen-ui-react-old';
|
|
8
|
+
import { ReactRequiredDependencyProvider as ReactRequiredDependencyProviderNew } from '@aws-amplify/codegen-ui-react-new';
|
|
9
|
+
import { StudioComponent } from '@aws-amplify/codegen-ui-new';
|
|
7
10
|
|
|
8
|
-
|
|
11
|
+
const isUpdatedSchema = (schemas: StudioComponent[]) => {
|
|
12
|
+
return schemas.some(schema => schema.schemaVersion && schema.schemaVersion === '1.0');
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const getRequiredDependencies = (schemas: StudioComponent[]) => {
|
|
16
|
+
if (isUpdatedSchema(schemas)) {
|
|
17
|
+
return new ReactRequiredDependencyProviderNew().getRequiredDependencies();
|
|
18
|
+
}
|
|
19
|
+
return new ReactRequiredDependencyProvider().getRequiredDependencies();
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const notifyMissingPackages = (context: $TSContext, schemas: StudioComponent[]) => {
|
|
9
23
|
const args = extractArgs(context);
|
|
10
24
|
const localEnvFilePath = args.localEnvFilePath ?? pathManager.getLocalEnvFilePath();
|
|
11
25
|
if (!fs.existsSync(localEnvFilePath)) {
|
|
@@ -19,22 +33,20 @@ export const notifyMissingPackages = (context: $TSContext) => {
|
|
|
19
33
|
return;
|
|
20
34
|
}
|
|
21
35
|
const packageJson = JSONUtilities.readJson(packageJsonPath) as { dependencies: { [key: string]: string } };
|
|
22
|
-
|
|
23
|
-
const packageIsInstalled = Object.keys(packageJson.dependencies).includes(
|
|
36
|
+
getRequiredDependencies(schemas).forEach((dependency: $TSAny) => {
|
|
37
|
+
const packageIsInstalled = Object.keys(packageJson.dependencies).includes(dependency.dependencyName);
|
|
24
38
|
if (!packageIsInstalled) {
|
|
25
|
-
printer.warn(`UIBuilder components required "${packageName}" that is not in your package.json. Run \`npm install ${packageName}\``);
|
|
26
|
-
} else if (!packageVersionMatches(REQUIRED_PACKAGES[packageName], packageJson.dependencies[packageName])) {
|
|
27
39
|
printer.warn(
|
|
28
|
-
`UIBuilder components
|
|
40
|
+
`UIBuilder components required "${dependency.dependencyName}" that is not in your package.json. Run \`npm install "${dependency.dependencyName}@${dependency.supportedSemVerPattern}"\`. ${dependency.reason}`,
|
|
41
|
+
);
|
|
42
|
+
} else if (!rangeSubset(packageJson.dependencies[dependency.dependencyName], dependency.supportedSemVerPattern)) {
|
|
43
|
+
printer.warn(
|
|
44
|
+
`UIBuilder components requires version "${dependency.supportedSemVerPattern}" of "${
|
|
45
|
+
dependency.dependencyName
|
|
46
|
+
}". You currently are on version "${packageJson.dependencies[dependency.dependencyName]}". Run \`npm install "${
|
|
47
|
+
dependency.dependencyName
|
|
48
|
+
}@${dependency.supportedSemVerPattern}"\`. ${dependency.reason}`,
|
|
29
49
|
);
|
|
30
50
|
}
|
|
31
51
|
});
|
|
32
52
|
};
|
|
33
|
-
|
|
34
|
-
const packageVersionMatches = (requiredVersion: string, existingVersion: string) => {
|
|
35
|
-
if (requiredVersion === '*') {
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return requiredVersion === existingVersion;
|
|
40
|
-
};
|