-
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: support modelgen without an amplify project being initialized
- Loading branch information
1 parent
e7ba7f8
commit aa9145e
Showing
4 changed files
with
245 additions
and
72 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
23 changes: 23 additions & 0 deletions
23
packages/amplify-codegen/src/utils/getModelSchemaPathParam.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,23 @@ | ||
const path = require('path'); | ||
|
||
/** | ||
* Retrieve the specified model schema path parameter, returning as an absolute path. | ||
* @param context the CLI invocation context | ||
* @returns the absolute path to the model schema path | ||
*/ | ||
function getModelSchemaPathParam(context) { | ||
const modelSchemaPathParam = context.parameters?.options?.['model-schema']; | ||
if ( !modelSchemaPathParam ) { | ||
return null; | ||
} | ||
let projectRoot; | ||
try { | ||
context.amplify.getProjectMeta(); | ||
projectRoot = context.amplify.getEnvInfo().projectPath; | ||
} catch (e) { | ||
projectRoot = process.cwd(); | ||
} | ||
return path.isAbsolute(modelSchemaPathParam) ? modelSchemaPathParam : path.join(projectRoot, modelSchemaPathParam); | ||
} | ||
|
||
module.exports = getModelSchemaPathParam; |
Oops, something went wrong.