-
Notifications
You must be signed in to change notification settings - Fork 820
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(amplify-provider-awscloudformation): refactor of the exporting resources * feat(amplify-provider-awscloudformation): refactored export to write files to external path * refactor: clean up * refactor: remove unused * fix: mispelled url * feat: fall back on push globing and template url * feat: export * feat: modify generation of lambda layer version content * fix(amplify-category-function): lambda layers filter stacks * feat: added command line for export * test(amplify-provider-awscloudformation): added tests for export resources * perf: removed unused * refactor: removed unused * fix: make the tags file pascal case * docs(amplify-provider-awscloudformation): added some documentation * feat(amplify-provider-awscloudformation): added warning and folder perms * fix: check in constants change * refactor: addressing PR feedback * refactor: es6 export * feat: minor changes for integration testing * refactor: pr comments * fix: cleared commented out code removed backup * ci: revert config file to main
- Loading branch information
1 parent
76b0e70
commit 03dde65
Showing
25 changed files
with
1,710 additions
and
59 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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import * as fs from 'fs-extra'; | ||
import { ExportPathValidationError } from '../errors'; | ||
|
||
/** | ||
* Validates whether the path is a directory | ||
* @throws {ExportPathValidationError} if path not valid | ||
* @param directoryPath to validate | ||
*/ | ||
export function validateExportDirectoryPath(directoryPath: any) { | ||
if (typeof directoryPath !== 'string') { | ||
throw new ExportPathValidationError(`${directoryPath} is not a valid path specified by --out`); | ||
} | ||
|
||
if (!fs.existsSync(directoryPath)) { | ||
throw new ExportPathValidationError(`${directoryPath} does not exist`); | ||
} | ||
|
||
const stat = fs.lstatSync(directoryPath); | ||
if (!stat.isDirectory()) { | ||
throw new ExportPathValidationError(`${directoryPath} is not a valid directory`); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
"console", | ||
"delete", | ||
"env", | ||
"export", | ||
"help", | ||
"init", | ||
"logout", | ||
|
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,31 @@ | ||
import { $TSContext, ExportPathValidationError } from 'amplify-cli-core'; | ||
import { printer } from 'amplify-prompts'; | ||
import * as chalk from 'chalk'; | ||
import * as fs from 'fs-extra'; | ||
import * as path from 'path'; | ||
export const run = async (context: $TSContext) => { | ||
const options = context.input.options; | ||
|
||
const showHelp = !options || options.help || !options.out; | ||
if (showHelp) { | ||
printer.blankLine(); | ||
printer.info("'amplify export', Allows you to integrate your backend into an external deployment tool"); | ||
printer.blankLine(); | ||
printer.info(`${chalk.yellow('--cdk')} Export all resources with cdk comatibility`); | ||
printer.info(`${chalk.yellow('--out')} Root directory of cdk project`); | ||
printer.blankLine(); | ||
printer.info(`Example: ${chalk.green('amplify export --cdk --out ~/myCDKApp')}`); | ||
printer.blankLine(); | ||
return; | ||
} | ||
|
||
await context.amplify.showResourceTable(); | ||
const resources = await context.amplify.getResourceStatus(); | ||
const providerPlugin = context.amplify.getProviderPlugins(context); | ||
const providers = Object.keys(providerPlugin); | ||
const exportPath = path.resolve(context.input.options['out']); | ||
for await (const provider of providers) { | ||
const plugin = await import(providerPlugin[provider]); | ||
await plugin.exportResources(context, resources, exportPath); | ||
} | ||
}; |
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,16 @@ | ||
import { nspawn as spawn, getCLIPath } from '..'; | ||
|
||
export function exportBackend(cwd: string, settings: { exportPath: string }): Promise<void> { | ||
return new Promise((resolve, reject) => { | ||
spawn(getCLIPath(), ['export', '--out', settings.exportPath], { cwd, stripColors: true }) | ||
.wait('For more information: docs.amplify.aws/cli/export') | ||
.sendEof() | ||
.run((err: Error) => { | ||
if (!err) { | ||
resolve(); | ||
} else { | ||
reject(err); | ||
} | ||
}); | ||
}); | ||
} |
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.