From 7f953954a25071d55e61d33ec9f6641fe283de9c Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Thu, 28 Dec 2017 14:05:57 +0200 Subject: Initial commit --- .gitignore | 2 ++ .npmignore | 1 + README.md | 28 ++++++++++++++++++++++++++++ package.json | 25 +++++++++++++++++++++++++ src/index.ts | 26 ++++++++++++++++++++++++++ src/tag/index.ts | 5 +++++ src/tag/scss.ts | 4 ++++ src/tag/tag.ts | 11 +++++++++++ tsconfig.json | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ yarn.lock | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 10 files changed, 204 insertions(+) create mode 100644 .gitignore create mode 100644 .npmignore create mode 100644 README.md create mode 100644 package.json create mode 100644 src/index.ts create mode 100644 src/tag/index.ts create mode 100644 src/tag/scss.ts create mode 100644 src/tag/tag.ts create mode 100644 tsconfig.json create mode 100644 yarn.lock diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..76add87 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules +dist \ No newline at end of file diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..e831038 --- /dev/null +++ b/.npmignore @@ -0,0 +1 @@ +src \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..2690125 --- /dev/null +++ b/README.md @@ -0,0 +1,28 @@ +# Create riot component + +Create a component skeleton for [riot.js](http://riotjs.com/). Designed to be used with ES6 import syntax and SASS. + +## Installation + +### With yarn +`yarn global add create-riot-component` + +### With npm +`npm install -g create-riot-component` + +## Usage + +`create-riot-component [component-name]` + +This command would create the following directory structure: + +``` +component-name + - component-name.tag + - component-name.scss + - index.js // for importing the directory +``` + +## Author + +Jan Tuomi 2017 \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..15359cc --- /dev/null +++ b/package.json @@ -0,0 +1,25 @@ +{ + "name": "create-riot-component", + "version": "1.0.0", + "description": "Create ES6 riot.js component", + "main": "dist/index.js", + "bin": { + "create-riot-component": "./dist/index.js" + }, + "author": "Jan Tuomi", + "license": "MIT", + "scripts": { + "build": "tsc --outDir dist", + "prepublish": "npm run build" + }, + "types": "dist/index.d.ts", + "dependencies": { + "@types/es6-promise": "^0.0.33", + "commander": "^2.12.2", + "fs-extra": "^5.0.0" + }, + "devDependencies": { + "@types/fs-extra": "^5.0.0", + "typescript": "^2.6.2" + } +} diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..2a2834b --- /dev/null +++ b/src/index.ts @@ -0,0 +1,26 @@ +#!/usr/bin/env node + +import * as fs from 'fs-extra'; +import * as program from 'commander'; +import tag from './tag/tag'; +import scss from './tag/scss'; +import index from './tag/index'; + +async function main(tagName: string) { + const name = tagName.toLocaleLowerCase(); + console.log(`Creating component ${name}...`); + + fs.mkdir(name); + await fs.writeFile(`${name}/${name}.tag`, tag.replace(/\$name/g, name)); + await fs.writeFile(`${name}/${name}.scss`, scss.replace(/\$name/g, name)); + await fs.writeFile(`${name}/${name}.js`, index.replace(/\$name/g, name)); +}; + +program + .version('1.0.0') + .arguments('') + .action(name => { + main(name); + }) + .usage('create-riot-component [name]') + .parse(process.argv); \ No newline at end of file diff --git a/src/tag/index.ts b/src/tag/index.ts new file mode 100644 index 0000000..cc2c768 --- /dev/null +++ b/src/tag/index.ts @@ -0,0 +1,5 @@ +const output = `import tag from './$name.tag'; +export default tag; +`; + +export default output; \ No newline at end of file diff --git a/src/tag/scss.ts b/src/tag/scss.ts new file mode 100644 index 0000000..0c3e74e --- /dev/null +++ b/src/tag/scss.ts @@ -0,0 +1,4 @@ +const output = `/* Write your SCSS here */ +`; + +export default output; \ No newline at end of file diff --git a/src/tag/tag.ts b/src/tag/tag.ts new file mode 100644 index 0000000..db1fc93 --- /dev/null +++ b/src/tag/tag.ts @@ -0,0 +1,11 @@ +const output = `<$name> + + + + +`; + +export default output; \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..99e144b --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,55 @@ +{ + "compilerOptions": { + /* Basic Options */ + "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ + "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ + // "lib": [], /* Specify library files to be included in the compilation: */ + //"allowJs": false, /* Allow javascript files to be compiled. */ + // "checkJs": true, /* Report errors in .js files. */ + // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ + // "declaration": true, /* Generates corresponding '.d.ts' file. */ + // "sourceMap": true, /* Generates corresponding '.map' file. */ + // "outFile": "./", /* Concatenate and emit output to single file. */ + // "outDir": "./", /* Redirect output structure to the directory. */ + // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "removeComments": true, /* Do not emit comments to output. */ + // "noEmit": true, /* Do not emit outputs. */ + // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ + // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ + + /* Strict Type-Checking Options */ + "strict": true, /* Enable all strict type-checking options. */ + //"noImplicitAny": false, /* Raise error on expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* Enable strict null checks. */ + // "strictFunctionTypes": true, /* Enable strict checking of function types. */ + // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ + // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + + /* Additional Checks */ + // "noUnusedLocals": true, /* Report errors on unused locals. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + + /* Module Resolution Options */ + // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ + // "typeRoots": [], /* List of folders to include type definitions from. */ + // "types": [], /* Type declaration files to be included in compilation. */ + // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ + + /* Source Map Options */ + // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ + // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ + + /* Experimental Options */ + // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ + // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + } +} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 0000000..9e34701 --- /dev/null +++ b/yarn.lock @@ -0,0 +1,47 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@types/es6-promise@^0.0.33": + version "0.0.33" + resolved "https://registry.yarnpkg.com/@types/es6-promise/-/es6-promise-0.0.33.tgz#280a707e62b1b6bef1a86cc0861ec63cd06c7ff3" + +"@types/fs-extra@^5.0.0": + version "5.0.0" + resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-5.0.0.tgz#d3e225b35eb5c6d3a5a782c28219df365c781413" + dependencies: + "@types/node" "*" + +"@types/node@*": + version "8.5.2" + resolved "https://registry.yarnpkg.com/@types/node/-/node-8.5.2.tgz#83b8103fa9a2c2e83d78f701a9aa7c9539739aa5" + +commander@^2.12.2: + version "2.12.2" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.12.2.tgz#0f5946c427ed9ec0d91a46bb9def53e54650e555" + +fs-extra@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-5.0.0.tgz#414d0110cdd06705734d055652c5411260c31abd" + dependencies: + graceful-fs "^4.1.2" + jsonfile "^4.0.0" + universalify "^0.1.0" + +graceful-fs@^4.1.2, graceful-fs@^4.1.6: + version "4.1.11" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" + +jsonfile@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb" + optionalDependencies: + graceful-fs "^4.1.6" + +typescript@^2.6.2: + version "2.6.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.6.2.tgz#3c5b6fd7f6de0914269027f03c0946758f7673a4" + +universalify@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.1.tgz#fa71badd4437af4c148841e3b3b165f9e9e590b7" -- cgit v1.3