-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: experimental cdk migrate command #25859
Merged
+214
−61
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
b53855e
experimental cdk migrate command
b3dc8e1
fix typescript erroring
1801196
add helpful import message
e71d63e
fix aliases to make it work
RomainMuller 483c431
bring in some automation to avoid manual operations
RomainMuller 5b5afee
Leverage list of supported languages
RomainMuller ad081a0
add warning to command
089df4f
Merge branch 'main' into experimental/migrate
HBobertz d57c47c
better warning messages
8060c44
Merge branch 'main' into experimental/migrate
HBobertz e50a4ef
modified how we get nocti for cdk migrate
84b10c4
Merge branch 'main' into experimental/migrate
HBobertz a2a26f3
remove mkdir as it was having idempotency issues
0bdd473
update readme to reflect new nocti consumption flow
94687d8
git fixes for submodule stuff
d51b074
modify generate to delete the generated package json
2a85864
Update warning wording to be more professional
HBobertz dbde5b7
Merge branch 'main' into experimental/migrate
HBobertz 00eeede
update third party licensces
4ca5d2e
fix alpha gen script
95cf39c
change default input path
7444399
Merge branch 'main' into experimental/migrate
HBobertz a8665cd
Merge branch 'main' into experimental/migrate
HBobertz b3ab9f8
Merge branch 'main' into experimental/migrate
HBobertz a2fd134
add npx so ts-node can be called correctly
MrArnoldPalmer 1727e02
Merge branch 'main' into experimental/migrate
HBobertz afbe3b3
fix irrelevant bug
da4280b
use yarn --silent instead of npx
RomainMuller 2efd438
Hoist ts-node to root package.json + uniformize typescript deps
RomainMuller e15f084
adjust esbuild packaging to correctly bundle WASM resource
RomainMuller 6e06664
Merge branch 'main' into experimental/migrate
HBobertz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Empty file.
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,16 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
commit=${CODEBUILD_RESOLVED_SOURCE_VERSION:-} | ||
# CODEBUILD_RESOLVED_SOURCE_VERSION is not defined (i.e. local build or CodePipeline build), | ||
# use the HEAD commit hash | ||
if [ -z "${commit}" ]; then | ||
commit="$(git rev-parse --verify HEAD)" | ||
fi | ||
|
||
cat > build-info.json <<HERE | ||
{ | ||
"comment": "Generated at $(date -u +"%Y-%m-%dT%H:%M:%SZ") by generate.sh", | ||
"commit": "${commit:0:7}" | ||
} | ||
HERE |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
const baseConfig = require('@aws-cdk/cdk-build-tools/config/eslintrc'); | ||
baseConfig.ignorePatterns.push('lib/init-templates/**/typescript/**/*.ts'); | ||
baseConfig.ignorePatterns.push('test/integ/cli/sam_cdk_integ_app/**/*.ts'); | ||
baseConfig.ignorePatterns.push('vendor/noctilucent/**/*.ts'); | ||
baseConfig.parserOptions.project = __dirname + '/tsconfig.json'; | ||
module.exports = baseConfig; |
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 |
---|---|---|
|
@@ -39,3 +39,6 @@ test/integ/cli/*.d.ts | |
.DS_Store | ||
|
||
junit.xml | ||
|
||
# Exclude the noctilucent WASM package | ||
lib/vendor/noctilucent/ |
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 |
---|---|---|
|
@@ -28,3 +28,6 @@ tsconfig.json | |
# exclude cdk artifacts | ||
**/cdk.out | ||
junit.xml | ||
|
||
# exclude noctilucent source | ||
/vendor/noctilucent/ |
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,71 @@ | ||
import * as fs from 'fs'; | ||
import * as path from 'path'; | ||
import { initializeProject, availableInitTemplates } from '../../lib/init'; | ||
import { warning } from '../logging'; | ||
import * as nocti from '../vendor/noctilucent'; | ||
|
||
/** The list of languages supported by the built-in noctilucent binary. */ | ||
export const MIGRATE_SUPPORTED_LANGUAGES: readonly string[] = nocti.supported_languages(); | ||
|
||
export async function cliMigrate( | ||
inputpath: string = process.cwd() + '/../template.txt', | ||
language = MIGRATE_SUPPORTED_LANGUAGES[0], | ||
generateOnly = false, | ||
outputpath = process.cwd(), | ||
) { | ||
warning('This is an experimental feature. We make no guarantees about the outcome or stability of the functionality.'); | ||
const type = 'default'; // "default" is the default type (and maps to 'app') | ||
const template = (await availableInitTemplates()).find(t => t.hasName(type!)); | ||
if (!template) { | ||
throw new Error(`couldn't find template for ${type} app type, this should never happen`); | ||
} | ||
|
||
if (!MIGRATE_SUPPORTED_LANGUAGES.includes(language)) { | ||
throw new Error(`Unsupported language for cdk migrate: ${language}. Supported languages are: ${MIGRATE_SUPPORTED_LANGUAGES.join(', ')}`); | ||
} | ||
|
||
await initializeProject(template, language, true, generateOnly, outputpath); | ||
const template_file = fs.readFileSync(inputpath, 'utf8'); | ||
const generated_app = nocti.transmute(template_file, language); | ||
|
||
// clear out the init'd bin/lib files to replace with our own | ||
delete_files(outputpath + '/lib/'); | ||
|
||
// we hardcode everything to be called noctstack still so this works for now. | ||
// Will change this to be much smarter once we can change stack name in noct | ||
const bin_app = `#!/usr/bin/env node | ||
import 'source-map-support/register'; | ||
import * as cdk from 'aws-cdk-lib'; | ||
import { NoctStack } from '../lib/generated_stack'; | ||
|
||
const app = new cdk.App(); | ||
new NoctStack(app, 'NoctStack', { | ||
/* If you don't specify 'env', this stack will be environment-agnostic. | ||
* Account/Region-dependent features and context lookups will not work, | ||
* but a single synthesized template can be deployed anywhere. */ | ||
|
||
/* Uncomment the next line to specialize this stack for the AWS Account | ||
* and Region that are implied by the current CLI configuration. */ | ||
// env: { account: process.env.CDK_DEFAULT_ACCOUNT, region: process.env.CDK_DEFAULT_REGION }, | ||
|
||
/* Uncomment the next line if you know exactly what Account and Region you | ||
* want to deploy the stack to. */ | ||
// env: { account: '123456789012', region: 'us-east-1' }, | ||
|
||
/* For more information, see https://docs.aws.amazon.com/cdk/latest/guide/environments.html */ | ||
});`; | ||
const myname = path.basename(outputpath); | ||
fs.writeFileSync(outputpath + '/lib/' + 'generated_stack.ts', generated_app); | ||
fs.writeFileSync(outputpath + '/bin/' + `${myname}.ts`, bin_app); | ||
} | ||
|
||
function delete_files(filepath: string) { | ||
fs.readdir(filepath, (err, files) => { | ||
if (err) throw err; | ||
for (const file of files) { | ||
fs.unlink(filepath + file, (cause) => { | ||
if (cause) throw cause; | ||
}); | ||
} | ||
}); | ||
} |
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,13 @@ | ||
## Vendored-in dependencies | ||
|
||
The dependencies in this directory are checked out using the `gen` script. | ||
This will fetch and clone the noctilucent crate and generate the wasm code if | ||
that has not been done already, ensuring the dependencies are adequately | ||
checked out. | ||
|
||
In order to update the notcilucent crate, run the ./generate.sh script. If you wish | ||
to update to a different noctilucent commit hash instead of the one provided, modify | ||
the hash in the generate.sh script and then rerun ./generate.sh | ||
|
||
The `THIRD_PARTY_LICENSES` file might need updating accordingly, which can be | ||
automatically done by running `yarn pkglint`. |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to double-take: why is this an option here, but not exposed as an argument?
Even if right now it has a single value, it can be expanded in the future (based on the comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah so this is basically just to get the init funcitonality to work. I'm happy to just pass the hardcoded string into the initliazeproject but I thought I'd be explicit about wat the default meant.