-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update imports generated for flutter datastore plugin dependency (
#382) (#388) * chore(amplify-codegen): change flutter import path from datastore to core (#380) * feat(appsync-modelgen-plugin): Change flutter datastore models dependency to use amplify_core * feat(appsync-modelgen-plugin): add amplify_flutter version check to determine datastore dependency import * fix(appsync-modelgen-plugin): correct indentation for error message * fix(appsync-modelgen-plugin): run linter * fix(amplify-codegen): update unit tests * fix(amplify-codegen): lower minimum version to 0.4.0-rc.1 * fix(appsync-modelgen-plugin): remove duplicate .dart from imports Co-authored-by: Travis Sheppard <[email protected]> Co-authored-by: Dane Pilcher <[email protected]> Co-authored-by: Phani Srikar Edupuganti <[email protected]> Co-authored-by: Travis Sheppard <[email protected]>
- Loading branch information
1 parent
ec68b8e
commit 329e513
Showing
11 changed files
with
1,046 additions
and
358 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 4 additions & 27 deletions
31
packages/amplify-codegen/src/utils/validateAmplifyFlutterCapableZeroThreeFeatures.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,9 @@ | ||
const yaml = require('js-yaml'); | ||
const path = require('path'); | ||
const fs = require('fs-extra'); | ||
const semver = require('semver'); | ||
const { validateAmplifyFlutterVersion } = require('./validateAmplifyFlutterVersion'); | ||
|
||
const PUBSPEC_LOCK_FILE_NAME = 'pubspec.lock'; | ||
const MINIMUM_VERSION_CONSTRAIN = '>= 0.3.0 || >= 0.3.0-rc.2'; | ||
const MINIMUM_VERSION_CONSTRAINT = '>= 0.3.0 || >= 0.3.0-rc.2'; | ||
|
||
function validateAmplifyFlutterCapableZeroThreeFeatures(projectRoot) { | ||
try { | ||
const lockFile = yaml.load(fs.readFileSync(path.join(projectRoot, PUBSPEC_LOCK_FILE_NAME), 'utf8')); | ||
// check resolved dependency version written pubspec.lock file | ||
const { version } = lockFile.packages.amplify_flutter || {}; | ||
// For this util function it check only if the amplify_flutter version is great than the minimum version | ||
// and it's not concerned with prerelease range, hence including prerelease to ensure | ||
// 0.4.0-rc.2 > 0.3.0-rc.2 is true | ||
if (semver.satisfies(version, MINIMUM_VERSION_CONSTRAIN, { includePrerelease: true })) { | ||
return true; | ||
} | ||
return false; | ||
} catch (e) { | ||
if (e.stack) { | ||
console.log(e.stack); | ||
console.log(e.message); | ||
} | ||
|
||
console.log('An error occurred while parsing ' + PUBSPEC_LOCK_FILE_NAME + '.'); | ||
return false; | ||
} | ||
return validateAmplifyFlutterVersion(projectRoot, MINIMUM_VERSION_CONSTRAINT); | ||
} | ||
|
||
module.exports = { validateAmplifyFlutterCapableZeroThreeFeatures, PUBSPEC_LOCK_FILE_NAME, MINIMUM_VERSION_CONSTRAIN }; | ||
module.exports = { validateAmplifyFlutterCapableZeroThreeFeatures }; |
9 changes: 9 additions & 0 deletions
9
packages/amplify-codegen/src/utils/validateAmplifyFlutterCoreLibraryDependency.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const { validateAmplifyFlutterVersion } = require('./validateAmplifyFlutterVersion'); | ||
|
||
const MINIMUM_VERSION_CONSTRAINT = '>= 0.4.0 || >= 0.4.0-rc.1'; | ||
|
||
function validateAmplifyFlutterCoreLibraryDependency(projectRoot) { | ||
return validateAmplifyFlutterVersion(projectRoot, MINIMUM_VERSION_CONSTRAINT); | ||
} | ||
|
||
module.exports = { validateAmplifyFlutterCoreLibraryDependency }; |
29 changes: 29 additions & 0 deletions
29
packages/amplify-codegen/src/utils/validateAmplifyFlutterVersion.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const yaml = require('js-yaml'); | ||
const path = require('path'); | ||
const fs = require('fs-extra'); | ||
const semver = require('semver'); | ||
|
||
const PUBSPEC_LOCK_FILE_NAME = 'pubspec.lock'; | ||
|
||
function validateAmplifyFlutterVersion(projectRoot, versionConstraint) { | ||
try { | ||
const lockFile = yaml.load(fs.readFileSync(path.join(projectRoot, PUBSPEC_LOCK_FILE_NAME), 'utf8')); | ||
// check resolved dependency version written pubspec.lock file | ||
const { version } = lockFile.packages.amplify_flutter || {}; | ||
// For this util function it check only if the amplify_flutter version satisfies the given version constraint | ||
if (semver.satisfies(version, versionConstraint, { includePrerelease: true })) { | ||
return true; | ||
} | ||
return false; | ||
} catch (e) { | ||
if (e.stack) { | ||
console.log(e.stack); | ||
console.log(e.message); | ||
} | ||
|
||
console.log('An error occurred while parsing ' + PUBSPEC_LOCK_FILE_NAME + '.'); | ||
return false; | ||
} | ||
} | ||
|
||
module.exports = { validateAmplifyFlutterVersion, PUBSPEC_LOCK_FILE_NAME }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.