Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

add vscode linting#2

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ShMcK merged 1 commit intomasterfromfeature/lint
May 30, 2020
Merged
Show file tree
Hide file tree
Changes fromall 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
3 changes: 1 addition & 2 deletions.gitignore
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
node_modules
.vscode
node_modules
5 changes: 5 additions & 0 deletions.vscode/extensions.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": ["dbaeumer.vscode-eslint"]
}
10 changes: 10 additions & 0 deletions.vscode/settings.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
{
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": false,
"source.fixAll": true
},
"eslint.validate": ["javascript"],
"files.exclude": {},
"git.alwaysSignOff": true
}
18 changes: 9 additions & 9 deletionsREADME.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,15 +18,14 @@ npm install -g @coderoad/cli
## Create

```shell
$coderoad create
coderoad create
```

Create templates files in the current folder for the content and setup files.


## Build

```
```text
$ coderoad build [options]

options:
Expand All@@ -35,22 +34,22 @@ options:
-d, --dir Tutorial's local directory. Either --git or --dir should be provided.
-c, --code Branch that contains the code.
-s, --setup Branch that contains the TUTORIAL.md and coderoad.yaml files.
-o, --output (Optional) Save the configuration in the output file.
-o, --output (Optional) Save the configuration in the output file.
Log into the console if not set
-h, --help (Optional) Show the help message
```
```

Build the configuration file to be used by the extension to run the tutorial. The configuration file is created by matching the `level` and `step` ids between the `TUTORIAL.md` and `coderoad.yaml` files against git commit messages with the same ids. For example:


**TUTORIAL.md**

```markdown
...

## L10 This is a level with id = 10

This level has two steps...


### L10S1 First step

The first step with id L10S1. The Step id should start with the level id.
Expand All@@ -61,8 +60,9 @@ The second step...
```

**coderoad.yaml**

```yaml
...
---
levels:
- id: L10
config: {}
Expand DownExpand Up@@ -98,7 +98,7 @@ levels:

... and the commit messages

```
```text
commit 8e0e3a42ae565050181fdb68298114df21467a74 (HEAD -> v2, origin/v2)
Author: creator <author@email.com>
Date: Sun May 3 16:16:01 2020 -0700
Expand Down
126 changes: 63 additions & 63 deletionssrc/cli.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,85 @@
import arg from'arg';
import inquirer from'inquirer';
import simpleGit from'simple-git/promise';
import build from'./parse';
import create from'./create';
import fs from'fs';
import arg from"arg";
import inquirer from"inquirer";
import simpleGit from"simple-git/promise";
import build from"./parse";
import create from"./create";
import fs from"fs";

const localGit ='Local directory';
const remoteGit ='Git remote address';
const localGit ="Local directory";
const remoteGit ="Git remote address";

function parseArgumentsIntoOptions(rawArgs) {
const args = arg(
{
'--git': String,
'--dir': String,
'--code': String,
'--setup': String,
'--output': String,
'--help': Boolean,
'-g': '--git',
'-d': '--dir',
'-c': '--code',
'-s': '--setup',
'-o': '--output',
'-h': '--help',
"--git": String,
"--dir": String,
"--code": String,
"--setup": String,
"--output": String,
"--help": Boolean,
"-g": "--git",
"-d": "--dir",
"-c": "--code",
"-s": "--setup",
"-o": "--output",
"-h": "--help",
},
{
argv: rawArgs.slice(2),
}
);
return {
command: args['_'][0],
git: args['--git'],
dir: args['--dir'],
codeBranch: args['--code'],
setupBranch: args['--setup'],
output: args['--output'],
help: args['--help'] || false,
command: args["_"][0],
git: args["--git"],
dir: args["--dir"],
codeBranch: args["--code"],
setupBranch: args["--setup"],
output: args["--output"],
help: args["--help"] || false,
};
}

async function promptForMissingOptions(options) {

const questions = [];

// if no git remote addres is provided, assume current folder
if (!options.git && !options.dir) {

// check if the current dir is a valid repo
const git = simpleGit(process.cwd());
const isRepo = await git.checkIsRepo();

if (!isRepo) {

questions.push({
type:'list',
name:'source',
type:"list",
name:"source",
message: `The current directory (${process.cwd()}) is not a valid git repo. Would you like to provide a...`,
choices: [localGit, remoteGit],
default: localGit,
});

questions.push({
type: 'input',
name: 'localGit',
message: 'Please, provide a local directory of the valid git repository: ',
type: "input",
name: "localGit",
message:
"Please, provide a local directory of the valid git repository: ",
when: (answers) => answers.source === localGit,
});

questions.push({
type:'input',
name:'remoteGit',
message:'Please, provide the address of a remote git repository:',
type:"input",
name:"remoteGit",
message:"Please, provide the address of a remote git repository:",
when: (answers) => answers.source === remoteGit,
});
}
}
// if both local dir and remote repos are provided
else if (options.git && options.dir) {
questions.push({
type: 'list',
name: 'source',
message: 'A local git directory and a remote address were both provided. Please, choose either one or those to parse: ',
type: "list",
name: "source",
message:
"A local git directory and a remote address were both provided. Please, choose either one or those to parse: ",
choices: [localGit, remoteGit],
default: localGit,
});
Expand All@@ -89,18 +88,19 @@ async function promptForMissingOptions(options) {
// if the branch containing the code is not provided
if (!options.codeBranch) {
questions.push({
type:'input',
name:'codeBranch',
message:'Please, provide the branch with the code commits:',
type:"input",
name:"codeBranch",
message:"Please, provide the branch with the code commits:",
});
}

// if the branch containing the setup files is not provided
if (!options.setupBranch) {
questions.push({
type: 'input',
name: 'setupBranch',
message: 'Please, provide the branch with the setup files (coderoad.yaml and tutorial.md): ',
type: "input",
name: "setupBranch",
message:
"Please, provide the branch with the setup files (coderoad.yaml and tutorial.md): ",
});
}

Expand All@@ -112,8 +112,7 @@ async function promptForMissingOptions(options) {
if (answers.source) {
repo = answers.source === localGit ? options.dir : options.git;
isLocal = answers.source === localGit;
}
else {
} else {
repo = options.dir || options.git || process.cwd();
isLocal = options.git ? false : true;
}
Expand All@@ -129,35 +128,36 @@ async function promptForMissingOptions(options) {

export async function cli(args) {
let options = parseArgumentsIntoOptions(args);

// If help called just print the help text and exit
if (options.help) {
console.log('Docs can be found at github: https://github.com/coderoad/coderoad-cli/');
}
else if (!options.command) {
console.log(`The command is missing. Choose either 'create' or 'build' and its options.`)
}
else {
console.log(
"Docs can be found at github: https://github.com/coderoad/coderoad-cli/"
);
} else if (!options.command) {
console.log(
`The command is missing. Choose either 'create' or 'build' and its options.`
);
} else {
switch (options.command) {
case'build':
case"build":
// Otherwise, continue with the other options
options = await promptForMissingOptions(options);
console.log(options);
const config = await build(options);

if (config) {
if (options.output) {
fs.writeFileSync(options.output, JSON.stringify(config), 'utf8');
}
else {
fs.writeFileSync(options.output, JSON.stringify(config), "utf8");
} else {
console.log(JSON.stringify(config, null, 2));
}
}
break;
case'create':

case"create":
create(process.cwd());
break;
}
}
}
}
27 changes: 11 additions & 16 deletionssrc/create.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,30 @@
import ncp from'ncp';
import path from'path';
import { promisify } from'util';
import * as os from'os';
import ncp from"ncp";
import path from"path";
import { promisify } from"util";
import * as os from"os";

const copy = promisify(ncp);

const copyFiles = async (filePath) => {

const copyFiles = async (filePath) => {
try {

let filePath = new URL(import.meta.url).pathname;

if (os.platform() ==='win32') {
if (os.platform() ==="win32") {
// removes the leading drive letter from the path
filePath = filePath.substr(3);
}

const templateDirectory = path.resolve(
filePath, '..', 'templates',
);
const templateDirectory = path.resolve(filePath, "..", "templates");

const targetDirectory = process.cwd();

await copy(templateDirectory, targetDirectory, {
clobber: false,
});
}
catch(e) {
console.log('Error on creating the files:');
} catch (e) {
console.log("Error on creating the files:");
console.log(JSON.stringify(e, null, 1));
}
}
};

export default copyFiles;
export default copyFiles;
Loading

[8]ページ先頭

©2009-2025 Movatter.jp