Skip to content

Commit

Permalink
feat: pre-deploy pull, new login mechanism and pkg cli updates (#5941)
Browse files Browse the repository at this point in the history
Co-authored-by: Kaustav Ghosh <kaustav.ghosh19@gmail.com>
Co-authored-by: John Hockett <jhockett@users.noreply.github.com>
Co-authored-by: Diego Costantino <diego@diegocostantino.com>
  • Loading branch information
4 people committed Nov 30, 2020
1 parent 7d48378 commit 7274251
Show file tree
Hide file tree
Showing 91 changed files with 1,861 additions and 471 deletions.
26 changes: 19 additions & 7 deletions .circleci/config.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,16 @@ jobs:
startLocalRegistry "$(pwd)/.circleci/verdaccio.yaml"
setNpmRegistryUrlToLocal
loginToLocalRegistry
git config user.email not@used.com
git config user.name "Doesnt Matter"
yarn publish-to-verdaccio
unsetNpmRegistryUrl
- run:
name: Generate unified changelog
command: yarn ts-node scripts/unified-changelog.ts
command: |
git reset --hard HEAD
yarn update-versions
yarn ts-node scripts/unified-changelog.ts
- run:
name: Save new amplify GitHub tag
command: node scripts/echo-current-cli-version.js > .amplify-pkg-version
Expand Down Expand Up @@ -554,6 +559,13 @@ jobs:
key: amplify-pkg-binaries-{{ .Branch }}-{{ .Revision }}
- restore_cache:
key: amplfiy-pkg-tag-{{ .Branch }}-{{ .Revision }}
- run:
name: Compress binaries
command: |
cd out
tar zcvf amplify-pkg-macos.tgz amplify-pkg-macos
tar zcvf amplify-pkg-linux.tgz amplify-pkg-linux
tar zcvf amplify-pkg-win.exe.tgz amplify-pkg-win.exe
- run:
name: Publish Amplify CLI GitHub prerelease
command: |
Expand All @@ -567,14 +579,14 @@ jobs:
key: amplfiy-pkg-tag-{{ .Branch }}-{{ .Revision }}
- run:
name: Install packaged Amplify CLI
# replace command with curl -sL https://aws-amplify.github.io/amplify-cli/install | version=v$version bash before pushing
command: |
version=$(cat .amplify-pkg-version)
curl -sL https://aws-amplify.github.io/amplify-cli/install | bash
# TODO enable this check once the packaged CLI is renamed to amplify from amp
# - run:
# name: Sanity check install
# command: amplify version
curl -sL https://aws-amplify.github.io/amplify-cli/install | version=v$version bash
echo "export PATH=$PATH:$HOME/.amplify/bin" >> $BASH_ENV
- run:
name: Sanity check install
command: |
amplify version
github_release:
<<: *defaults
steps:
Expand Down
26 changes: 23 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,16 @@ jobs:
startLocalRegistry "$(pwd)/.circleci/verdaccio.yaml"
setNpmRegistryUrlToLocal
loginToLocalRegistry
git config user.email not@used.com
git config user.name "Doesnt Matter"
yarn publish-to-verdaccio
unsetNpmRegistryUrl
- run:
name: Generate unified changelog
command: yarn ts-node scripts/unified-changelog.ts
command: |
git reset --hard HEAD
yarn update-versions
yarn ts-node scripts/unified-changelog.ts
- run:
name: Save new amplify GitHub tag
command: node scripts/echo-current-cli-version.js > .amplify-pkg-version
Expand Down Expand Up @@ -620,6 +625,13 @@ jobs:
key: 'amplify-pkg-binaries-{{ .Branch }}-{{ .Revision }}'
- restore_cache:
key: 'amplfiy-pkg-tag-{{ .Branch }}-{{ .Revision }}'
- run:
name: Compress binaries
command: |
cd out
tar zcvf amplify-pkg-macos.tgz amplify-pkg-macos
tar zcvf amplify-pkg-linux.tgz amplify-pkg-linux
tar zcvf amplify-pkg-win.exe.tgz amplify-pkg-win.exe
- run:
name: Publish Amplify CLI GitHub prerelease
command: |
Expand All @@ -634,9 +646,17 @@ jobs:
key: 'amplfiy-pkg-tag-{{ .Branch }}-{{ .Revision }}'
- run:
name: Install packaged Amplify CLI
command: |
command: >
version=$(cat .amplify-pkg-version)
curl -sL https://aws-amplify.github.io/amplify-cli/install | bash
curl -sL https://aws-amplify.github.io/amplify-cli/install |
version=v$version bash
echo "export PATH=$PATH:$HOME/.amplify/bin" >> $BASH_ENV
- run:
name: Sanity check install
command: |
amplify version
github_release:
working_directory: ~/repo
docker: *ref_0
Expand Down
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,17 @@
"split-e2e-tests": "yarn ts-node ./scripts/split-e2e-tests.ts && git add .circleci/config.yml",
"pkg-clean": "rimraf build out pkg/node_modules pkg/yarn.lock",
"pkg-install": "cd pkg && yarn install --production",
"pkg-prune": "cd pkg && rimraf **/*.d.ts **/*.js.map **/*.d.ts.map **/README.md **/readme.md **/Readme.md **/CHANGELOG.md **/changelog.md **/Changelog.md **/HISTORY.md **/history.md **/History.md",
"pkg-transpile": "cd pkg && babel node_modules --copy-files -d ../build/node_modules",
"pkg-build": "cp pkg/package.json build/node_modules/package.json && pkg -t node12-macos-x64,node12-linux-x64,node12-win-x64 build/node_modules --out-path out",
"pkg-all": "yarn pkg-install && yarn pkg-transpile && yarn pkg-build",
"pkg-all": "yarn pkg-install && yarn pkg-prune && yarn pkg-transpile && yarn pkg-build",
"publish:master": "lerna publish --canary --force-publish --preid=alpha --exact --include-merged-tags --conventional-prerelease --yes",
"publish:beta": "lerna publish --exact --dist-tag=beta --preid=beta --conventional-commits --conventional-prerelease --message 'chore(release): Publish [ci skip]' --yes",
"publish:release": "lerna publish --conventional-commits --exact --yes --message 'chore(release): Publish [ci skip]'",
"publish:backendManager": "lerna publish --force-publish --preid=backend --dist-tag=backend --exact --include-merged-tags --conventional-prerelease --yes",
"publish:backendManager": "lerna publish --preid=backend --dist-tag=backend --exact --include-merged-tags --conventional-prerelease --conventional-commits --yes --no-commit-hooks --no-git-tag-version",
"postpublish:release": "git fetch . release:master && git push origin master",
"publish-to-verdaccio": "lerna publish --yes --no-git-tag-version --no-commit-hooks --no-push --exact --dist-tag=latest --conventional-commits",
"publish-to-verdaccio": "lerna publish --yes --no-commit-hooks --no-push --exact --dist-tag=latest --conventional-commits --no-git-tag-version",
"update-versions": "lerna version --yes --no-commit-hooks --no-push --exact --conventional-commits --no-git-tag-version",
"commit": "git-cz",
"coverage": "codecov || exit 0"
},
Expand Down
7 changes: 6 additions & 1 deletion packages/amplify-app/bin/amplify-app
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
#!/usr/bin/env node
require('../src/index.js').run();
const args = require('yargs').argv;
const path = args.path;
const platform = args.platform;
const framework = args.framework;

require('../src/index.js').run({ path, platform, framework });
1 change: 1 addition & 0 deletions packages/amplify-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"amplify-frontend-ios": "2.15.0",
"amplify-frontend-javascript": "2.18.2",
"chalk": "^3.0.0",
"execa":"^4.1.0",
"fs-extra": "^8.1.0",
"graphql": "^14.5.8",
"ini": "^1.3.5",
Expand Down
52 changes: 52 additions & 0 deletions packages/amplify-app/src/call-amplify.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
const execa = require('execa');
const path = require('path');

const isWin = process.platform.startsWith('win');
const amplify = isWin ? 'amplify.cmd' : 'amplify';
const amplifyDev = isWin ? 'amplify-dev.cmd' : 'amplify-dev';

const defaultOpts = {
inheritIO: true,
};

const callPkgAmplifyWin = async (args, opts) => {
opts = { ...defaultOpts, ...opts };
const { stdout, stderr } = await execa.command(`cmd /V /C "set PKG_EXECPATH= && ${process.argv[0]} ${args.join(' ')}"`, {
stdio: opts.inheritIO ? 'inherit' : undefined,
shell: 'cmd.exe',
});
if (stderr) {
throw new Error(`Amplify failed due to ${stderr}`);
}
return stdout;
};

const callPkgAmplifyNix = async (args, opts) => {
opts = { ...defaultOpts, ...opts };
const { stdout, stderr } = await execa.command(`PKG_EXECPATH=; ${process.argv[0]} ${args.join(' ')}`, {
stdio: opts.inheritIO ? 'inherit' : undefined,
shell: 'bash',
});
if (stderr) {
throw new Error(`Amplify failed due to ${stderr}`);
}
return stdout;
};

const callNodeAmplify = async (args, opts) => {
opts = { ...defaultOpts, ...opts };
const amplifyCmd = path.basename(process.argv[1]) === 'amplify-app-dev' ? amplifyDev : amplify;
const { stdout, stderr } = await execa(amplifyCmd, args, { stdio: opts.inheritIO ? 'inherit' : undefined });
if (stderr) {
throw new Error(`Amplify failed due to ${stderr}`);
}
return stdout;
};

const callPkgAmplify = isWin ? callPkgAmplifyWin : callPkgAmplifyNix;

const callAmplify = !!process.pkg ? callPkgAmplify : callNodeAmplify;

module.exports = {
callAmplify,
};

0 comments on commit 7274251

Please sign in to comment.