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

Add TypeScript template #62

Merged
merged 10 commits into from
Oct 20, 2022
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
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
12 changes: 4 additions & 8 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
{
"extends": [
"airbnb-base",
"prettier"
],
"extends": ["airbnb-base", "prettier"],
"env": {
"node": true,
"mocha": true
},
"parser": "babel-eslint",
"rules": {
"no-console": 0,
"import/extensions": ["error", { "js": "always" }],
"no-underscore-dangle": [
"error",
{
"allow": [
"_id"
]
"allow": ["_id"]
}
],
"import/no-named-as-default": 0
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,8 @@ cypress

# exclude directories used to test command outputs
/output

# exclude yarn directories
.yarn/
!.yarn/release
!.yarn/plugin
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yarn commitlint --edit $1
1 change: 1 addition & 0 deletions .husky/post-checkout
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yarn install
1 change: 1 addition & 0 deletions .husky/post-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
git status
1 change: 1 addition & 0 deletions .husky/post-merge
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yarn install
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yarn run-s lint test
1 change: 1 addition & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yarn run-s lint test
10 changes: 0 additions & 10 deletions .huskyrc

This file was deleted.

1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

801 changes: 801 additions & 0 deletions .yarn/releases/yarn-3.2.4.cjs

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-3.2.4.cjs
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ Move to a directory where you would like to clone a test project, e.g. `cd ~/my-

Run the CLI by using the full path from that directory to the `lib` folder inside this repository.

```
```bash
node ~/code/graasp/tools/graasp-cli/lib new
```
13 changes: 0 additions & 13 deletions babel.config.js

This file was deleted.

File renamed without changes.
56 changes: 31 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
"version": "0.4.2",
"author": "Juan Carlos Farah",
"description": "A CLI to create apps and labs for the Graasp ecosystem.",
"main": "lib/index.js",
"exports": "./src/index.js",
"type": "module",
spaenleh marked this conversation as resolved.
Show resolved Hide resolved
"contributors": [
"Basile Spaenlehauer"
],
"files": [
"lib"
],
"scripts": {
"test": "echo \"warning: no test specified\" && exit 0",
"compile": "babel src --out-dir lib --ignore **/__tests__",
"compile": "babel src --out-dir lib",
"hooks:uninstall": "node node_modules/husky/husky.js uninstall",
"hooks:install": "node node_modules/husky/husky.js install",
"prettier:check": "prettier --check 'src/**/*.js'",
Expand Down Expand Up @@ -42,32 +46,34 @@
},
"homepage": "https://github.com/graasp/graasp-cli#readme",
"devDependencies": {
"@babel/cli": "7.8.4",
"@babel/core": "7.9.0",
"@babel/preset-env": "7.9.0",
"@commitlint/cli": "8.3.5",
"@commitlint/config-conventional": "8.3.4",
"@babel/cli": "7.19.3",
"@babel/core": "7.19.3",
"@babel/preset-env": "7.19.4",
"@commitlint/cli": "17.1.2",
"@commitlint/config-conventional": "17.1.0",
"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",
"eslint": "8.25.0",
"eslint-config-airbnb-base": "15.0.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-import": "2.26.0",
"husky": "8.0.1",
"npm-run-all": "4.1.5",
"prettier": "2.1.1",
"standard-version": "7.1.0"
"prettier": "2.7.1",
"standard-version": "9.5.0"
},
"dependencies": {
"@babel/polyfill": "7.8.7",
"archiver": "5.0.0",
"bson-objectid": "1.3.0",
"del": "4.1.1",
"execa": "1.0.0",
"archiver": "5.3.1",
"del": "7.0.0",
"execa": "6.1.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",
"yargs": "12.0.5"
}
"fs-extra": "10.1.0",
"hosted-git-info": "5.1.0",
"inquirer": "9.1.3",
"lodash": "4.17.21",
"replace-in-file": "6.3.5",
"replace-json-property": "1.8.0",
"uuid": "9.0.0",
"yargs": "17.6.0"
},
"packageManager": "[email protected]"
}
48 changes: 41 additions & 7 deletions src/config.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,53 @@
export const DEFAULT_STARTER = 'graasp/graasp-app-starter-react';
// todo: change to the main branch
export const DEFAULT_STARTER = 'graasp/graasp-app-starter-ts#1/initRepo';
export const DEFAULT_FRAMEWORK = 'react';
export const DEFAULT_PATH = './';
export const BUILD_DIRECTORY = 'build';
export const ENV_TEMPLATE_FOLDER = '.env_templates';

// define types of starters that exist
export const STARTER_TYPE_APP = 'app';
export const STARTER_TYPE_LAB = 'lab';
spaenleh marked this conversation as resolved.
Show resolved Hide resolved
export const STARTER_TYPE_CHOICES = {
[STARTER_TYPE_APP]: 'App',
[STARTER_TYPE_LAB]: 'Lab',
};

// define frameworks supported
export const FRAMEWORK_REACT = 'react';
export const FRAMEWORK_CHOICES = {
[FRAMEWORK_REACT]: 'React',
};

// define available languages
export const LANGUAGE_TYPESCRIPT = 'ts';
export const LANGUAGE_JAVASCRIPT = 'js';
export const LANGUAGE_CHOICES = {
[LANGUAGE_TYPESCRIPT]: 'TypeScript',
[LANGUAGE_JAVASCRIPT]: 'JavaScript',
};

// combine options into an object to select the appropriate starter url
export const STARTERS = {
[STARTER_TYPE_APP]: {
[FRAMEWORK_REACT]: {
[LANGUAGE_TYPESCRIPT]: DEFAULT_STARTER,
},
},
};

export const BUILD_PACKAGE_NAME = 'package.zip';

// environments
export const TEST = 'test';
export const LOCAL = 'local';
export const DEV = 'dev';
export const PROD = 'prod';

// keys
export const AWS_ACCESS_KEY_ID_LENGTH = 20;
export const AWS_SECRET_ACCESS_KEY_LENGTH = 40;
export const DEV = 'development';

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

// replacement strings
// eslint-disable-next-line no-template-curly-in-string, no-useless-escape
export const YAML_TEMPLATE = 'GRAASP_TEMPLATE_FULL_NAME';
export const HTML_TEMPLATE = '%GRAASP_TEMPLATE_FULL_NAME%';
export const APP_ID_TEMPLATE = '{{GRAASP_APP_ID}}';
39 changes: 22 additions & 17 deletions src/createCli.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
import yargs from 'yargs';
import prompt from './prompt';
import { DEFAULT_STARTER } from './config';
import createPackageFile from './createPackageFile';
import prompt from './prompt.js';
import {
DEFAULT_STARTER,
FRAMEWORK_CHOICES,
STARTER_TYPE_CHOICES,
} from './config.js';
import createPackageFile from './createPackageFile.js';

const promisify = (fn) => (...args) => {
Promise.resolve(fn(...args)).then(
() => {
process.exit(0);
}
// err => report.panic(err)
);
};
const promisify =
(fn) =>
(...args) => {
Promise.resolve(fn(...args)).then(
() => {
process.exit(0);
}
// err => report.panic(err)
spaenleh marked this conversation as resolved.
Show resolved Hide resolved
);
};

const createCli = (argv) => {
const cli = yargs();
Expand Down Expand Up @@ -42,18 +48,17 @@ const createCli = (argv) => {
_.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)',
choices: Object.keys(FRAMEWORK_CHOICES),
describe: 'Set development framework (e.g. React, ...)',
})
.option('t', {
alias: 'type',
choices: ['app', 'lab'],
describe: 'Type of application (app or lab)',
choices: Object.keys(STARTER_TYPE_CHOICES),
describe: 'Type of application (app)',
})
.option('p', {
alias: 'path',
Expand All @@ -66,7 +71,7 @@ const createCli = (argv) => {
// package an app built files into a zip file
.command({
command: 'package',
desc: 'Package the build folder of an app into a zip file.',
describe: 'Package the build folder of an app into a zip file.',
handler: promisify(createPackageFile),
})
.wrap(cli.terminalWidth())
Expand Down
2 changes: 1 addition & 1 deletion src/createPackageFile.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import archiver from 'archiver';
import path from 'path';
import fs from 'fs';
import { DEFAULT_PATH, BUILD_DIRECTORY, BUILD_PACKAGE_NAME } from './config';
import { DEFAULT_PATH, BUILD_DIRECTORY, BUILD_PACKAGE_NAME } from './config.js';

const removeFileIfExists = (filepath) => {
try {
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env node

import createCli from './createCli';
import createCli from './createCli.js';

createCli(process.argv);
Loading