Skip to content
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

Promisify upload #46

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
18deca4
chore: add prettier style as usual for graasp apps
Jul 9, 2020
d248ef0
feat: add basic new command
Jul 9, 2020
70c76dc
feat: load dev env and deploy to aws
Jul 10, 2020
305efa0
refactor: rm test file and rm obsolet promisify()
Jul 10, 2020
53925c3
refactor: remove accidentally added bash script
Jul 10, 2020
68fb33b
feat: add options and validation
Jul 10, 2020
00f48a7
feat: invalidate cache after deployment
Jul 10, 2020
8ba8262
fix: allow console output in eslint
Jul 11, 2020
96d3531
feat: add a fancy progress bar
Jul 11, 2020
7ac7faa
fix: tag validation and accidental async
Jul 11, 2020
dc383ad
chore: add comment to RegExp and backshlashes
Jul 11, 2020
c37afb8
refactor: rename varIsDefined() to isDefined()
Jul 11, 2020
305cb3b
refactor: remove unused env varas from import
Jul 11, 2020
19eb223
refactor: replace unnamed func with arrow func
Jul 11, 2020
820b5f5
fix: minor changes based on feedback on pr
Jul 11, 2020
ad0f6f6
chore: remove obsolete comment
Jul 11, 2020
5687b3b
refactor: factor validation out
Jul 11, 2020
cb5650a
fix: use proper tag validation
Jul 17, 2020
6b38e41
chore: add explanation to regexp
Jul 17, 2020
f4b79ef
fix: remove default env
Jul 17, 2020
3cf0366
refactor: replace isdefined() with lodash
Jul 17, 2020
e85ac36
chore: enable linting warning for console log
Jul 18, 2020
baaa792
Merge branch 'master' of github.com:graasp/graasp-cli into deploy-cmd
Jul 26, 2020
2338ead
chore: try out promisify
Jul 26, 2020
4491092
chore: force commit with eslint errors
Jul 26, 2020
62ea0f8
feat: load sync aws credentials
Jul 26, 2020
89e8821
chore: update flag descriptions
Jul 26, 2020
7a288e8
chore: assemble error outputs in together
Jul 26, 2020
28a0dc5
chore: remove obsolete default env variable
Jul 26, 2020
3e19e19
chore: first version of promise for upload
Aug 9, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "airbnb-base",
"extends": ["airbnb-base", "prettier"],
"env": {
"node": true,
"mocha": true
Expand All @@ -9,11 +9,9 @@
"no-underscore-dangle": [
"error",
{
"allow": [
"_id"
]
"allow": ["_id"]
}
],
"import/no-named-as-default": 0
"import/no-named-as-default": "off"
}
}
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"trailingComma": "all",
"tabWidth": 2,
"semi": true,
"singleQuote": true
}
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,28 @@
"babel-eslint": "10.1.0",
"eslint": "6.8.0",
"eslint-config-airbnb-base": "14.1.0",
"eslint-config-prettier": "6.11.0",
"eslint-plugin-import": "2.20.1",
"husky": "4.2.3",
"npm-run-all": "4.1.5",
"standard-version": "7.1.0"
},
"dependencies": {
"@babel/polyfill": "7.8.7",
"async": "3.2.0",
"aws-sdk": "2.713.0",
"bson-objectid": "1.3.0",
"cli-progress": "3.8.2",
"del": "4.1.1",
"dotenv": "8.2.0",
"execa": "1.0.0",
"fs-exists-cached": "1.0.0",
"fs-extra": "7.0.1",
"hosted-git-info": "2.7.1",
"inquirer": "6.2.2",
"lodash": "4.17.19",
"recursive-readdir": "2.2.2",
"s3-node-client": "4.4.4",
"yargs": "12.0.5"
}
}
4 changes: 4 additions & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ export const AWS_SECRET_ACCESS_KEY_LENGTH = 40;

// file names
export const GRAASP_IGNORE_FILE = '.graaspignore';

// deploy settings
export const DEFAULT_BUILD_DIR = './build';
export const DEFAULT_APP_VERSION = 'latest';
80 changes: 52 additions & 28 deletions src/createCli.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import yargs from 'yargs';
import prompt from './prompt';
import { DEFAULT_STARTER } from './config';

const promisify = (fn) => (...args) => {
Promise.resolve(fn(...args)).then(
() => process.exit(0),
// err => report.panic(err)
);
};
import deploy from './deploy';
import {
DEFAULT_STARTER,
DEFAULT_BUILD_DIR,
DEFAULT_APP_VERSION,
} from './config';

const createCli = (argv) => {
const cli = yargs();
Expand All @@ -33,25 +31,52 @@ const createCli = (argv) => {
.command({
command: 'new',
desc: 'Create new Graasp app.',
builder: (_) => _.option('s', {
alias: 'starter',
type: 'string',
default: DEFAULT_STARTER,
describe: `Set starter. Defaults to ${DEFAULT_STARTER}`,
}).option('f', {
alias: 'framework',
type: 'string',
describe: 'Set development framework (e.g. React, Angular)',
}).option('t', {
alias: 'type',
choices: ['app', 'lab'],
describe: 'Type of application (app or lab)',
}).option('p', {
alias: 'path',
type: 'string',
describe: 'Path where project directory will be set up.',
}),
handler: promisify(prompt),
builder: (_) =>
_.option('s', {
alias: 'starter',
type: 'string',
default: DEFAULT_STARTER,
describe: `Set starter. Defaults to ${DEFAULT_STARTER}`,
})
.option('f', {
alias: 'framework',
type: 'string',
describe: 'Set development framework (e.g. React, Angular)',
})
.option('t', {
alias: 'type',
choices: ['app', 'lab'],
describe: 'Type of application (app or lab)',
})
.option('p', {
alias: 'path',
type: 'string',
describe: 'Path where project directory will be set up.',
}),
handler: prompt,
})
.command({
command: 'deploy',
desc: 'Deploy a Graasp app to AWS',
builder: (_) =>
_.option('t', {
alias: 'tag',
type: 'string',
default: DEFAULT_APP_VERSION,
describe: 'Tag the deployment with a version',
})
.option('e', {
alias: 'env',
type: 'string',
describe: 'Environment file used to load variables from',
})
.option('b', {
alias: 'build',
type: 'string',
default: DEFAULT_BUILD_DIR,
describe: 'Path to the build directory that will be deployed',
}),
handler: deploy,
})
.wrap(cli.terminalWidth())
.demandCommand(1, 'Pass --help to see all available commands and options.')
Expand All @@ -61,5 +86,4 @@ const createCli = (argv) => {
.parse(argv.slice(2));
};


export default createCli;
Loading