Repository: diogomoretti/javali Branch: master Commit: bc7591e055d4 Files: 44 Total size: 40.5 KB Directory structure: gitextract_o2bcdwhj/ ├── .editorconfig ├── .gitignore ├── .npmrc ├── .travis.yml ├── cli/ │ ├── index.js │ └── scripts/ │ ├── create.js │ ├── log.js │ ├── manager.js │ └── template.js ├── docs/ │ ├── CNAME │ ├── assets/ │ │ ├── css/ │ │ │ └── main.css │ │ └── favicons/ │ │ ├── browserconfig.xml │ │ └── site.webmanifest │ └── index.html ├── license.md ├── package.json ├── readme.md ├── templates/ │ ├── js/ │ │ ├── _babelrc │ │ ├── _editorconfig │ │ ├── _gitignore │ │ ├── _npmrc │ │ ├── _package │ │ ├── example/ │ │ │ └── index.html │ │ ├── license.md │ │ ├── readme.md │ │ ├── rollup.config.js │ │ └── src/ │ │ ├── main.js │ │ ├── my-library.js │ │ └── my-library.test.js │ └── ts/ │ ├── _babelrc │ ├── _editorconfig │ ├── _gitignore │ ├── _npmrc │ ├── _package │ ├── example/ │ │ └── index.html │ ├── license.md │ ├── readme.md │ ├── rollup.config.js │ ├── src/ │ │ ├── main.ts │ │ ├── my-library.test.ts │ │ └── my-library.ts │ ├── tsconfig.app.json │ └── tsconfig.json └── tests/ └── index.test.js ================================================ FILE CONTENTS ================================================ ================================================ FILE: .editorconfig ================================================ root = true [*] charset = utf-8 indent_style = space indent_size = 2 end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true ================================================ FILE: .gitignore ================================================ # See https://help.github.com/ignore-files/ for more about ignoring files. # dependencies node_modules # builds build dist .rpt2_cache # misc .DS_Store .env .env.local .env.development.local .env.test.local .env.production.local npm-debug.log* yarn-debug.log* yarn-error.log* package-lock.json ================================================ FILE: .npmrc ================================================ package-lock=false ================================================ FILE: .travis.yml ================================================ language: node_js node_js: - 'stable' before_install: - curl -o- -L https://yarnpkg.com/install.sh | bash install: - 'yarn install --immutable' script: - 'yarn lint' - 'yarn test' ================================================ FILE: cli/index.js ================================================ #!/usr/bin/env node const program = require('commander') const create = require('./scripts/create') const log = require('./scripts/log') const { version } = require('../package.json') let appName program .version(version) .arguments('') .option('-v, --version', 'version') .option('-t, --typescript', 'use typescript') .action((_appName) => { appName = _appName }) .parse(process.argv) if (appName) { create(appName, program.typescript) } else { log('Please, choose a name for your project ;)') } ================================================ FILE: cli/scripts/create.js ================================================ const fs = require('fs') const path = require('path').join const fullPath = require('path') const wrench = require('wrench') const runPath = process.cwd() const template = require('./template') const log = require('./log') const isFolderExistsSync = dir => { try { fs.accessSync(dir) return true } catch (e) { return false } } async function create (app, ts) { const fullPathFolder = path(runPath, app) const fullPathTemplate = path( fullPath.resolve(__dirname), `../../templates/${ts ? 'ts' : 'js'}` ) if (isFolderExistsSync(fullPathFolder)) { log(`Folder "${app}" already exists`, 'error') } else { const filesToRename = ['_babelrc', '_editorconfig', '_gitignore', '_npmrc', '_package'] const filesFinal = ['.babelrc', '.editorconfig', '.gitignore', '.npmrc', 'package.json'] await wrench.copyDirSyncRecursive(fullPathTemplate, fullPathFolder, { excludeHiddenUnix: false }) filesToRename.map((item, index) => { fs.renameSync( fullPath.resolve(fullPathFolder, item), fullPath.resolve(fullPathFolder, filesFinal[index]) ) }) log(`Project folder "${app}" was created =]`, 'success') template(app) } } module.exports = create ================================================ FILE: cli/scripts/log.js ================================================ const chalk = require('chalk') const log = (msg, type) => { const prefix = chalk.hex('#fef30a').bold('🐗 Javali ') let typeMessage = chalk.hex('#f5f5f5').bold(`➜ ${msg}`) if (type === 'success') { typeMessage = chalk.green.bold(`✔︎ ${msg}`) } else if (type === 'error') { typeMessage = chalk.red.bold(`✖ ${msg}`) } return console.log(`${prefix}${typeMessage}`) } module.exports = log ================================================ FILE: cli/scripts/manager.js ================================================ const shell = require('shelljs') const checkManager = () => shell.which('yarn') ? 'yarn' : 'npm' module.exports = checkManager ================================================ FILE: cli/scripts/template.js ================================================ const _ = require('lodash') const recursive = require('recursive-readdir') const fs = require('fs') const log = require('./log') const manager = require('./manager') const path = require('path').join const runPath = process.cwd() _.templateSettings = { evaluate: /{{([\s\S]+?)}}/g, interpolate: /{{=([\s\S]+?)}}/g, escape: /{{-([\s\S]+?)}}/g } async function run (app) { await recursive(path(runPath, app), ['.DS_Store'], (err, files) => { if (!err) { const managerType = manager() const cmdRun = (managerType === 'yarn') ? 'yarn' : 'npm run' const cmdInstall = (managerType === 'yarn') ? 'yarn' : 'npm install' files.forEach(file => { const fileContent = fs.readFileSync(file, 'utf8') const compiled = _.template(fileContent) const metadata = { appName: _.kebabCase(app), appManager: managerType, appCmd: cmdRun } try { fs.writeFileSync(file, compiled(metadata)) } catch (err) { log(err, 'error') } }) log(`To get started, run: "cd ${app} && ${cmdInstall} && ${cmdRun} start"`) } }) } module.exports = run ================================================ FILE: docs/CNAME ================================================ javali.js.org ================================================ FILE: docs/assets/css/main.css ================================================ :root { --main-color: #fef30a; --text-color: #232020; --font-title: 'Archivo', sans-serif; --font-code: 'PT Mono', monospace; } ::selection { background: var(--main-color); color: var(--text-color); } ::-moz-selection { background: var(--main-color); color: var(--text-color); } * { box-sizing: inherit; } html { font-size: 10px; box-sizing: border-box; scroll-behavior: smooth; height: 100%; } body { margin: 0; padding: 0; font-size: 1rem; background: #fff; height: 100%; color: var(--text-color); cursor: default; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; } .fork-button { display: block; position: absolute; width: 30em; padding: .5em 0; text-align: center; text-transform: uppercase; text-decoration: none; font-size: 1.2em; font-weight: bold; color: var(--text-color); background: var(--main-color); transform: rotate(45deg); top: 5em; right: -9em; z-index: 10; } /* Header */ .header { position: relative; display: flex; flex-direction: column; width: 100%; height: 100%; overflow: hidden; border-top: 5px solid var(--main-color); padding: 1em 2em 0; } .header-top { display: flex; max-width: 1040px; margin: 0 auto; width: 100%; } .header-column { flex: 1; } .header-column--menu { display: flex; justify-content: flex-end; align-items: center; } .header-logo img { max-width: 200px; } /* Menu */ .header-menu-list { list-style: none; margin: 0; padding: 1.2em 0 0 0; display: flex; } .header-menu-list li:not(:first-child) { margin-left: 5em; } .header-menu-list a { position: relative; font-family: var(--font-title); font-size: 1.4rem; font-weight: 600; text-transform: uppercase; text-decoration: none; color: var(--text-color); padding: .6em 0; border-radius: 3px; transition: background .5s ease; } .header-menu-list a:after { content: ""; bottom: 0; display: block; height: 2px; left: 50%; position: absolute; background: var(--main-color); transition: width .3s ease 0s, left .3s ease 0s; width: 0; } .header-menu-list a:hover:after { width: 100%; left: 0; } .header-main { display: flex; align-items: center; justify-content: center; height: 100%; } .header-main-content { max-width: 800px; margin: -6em auto 0; text-align: center; } .header-main-title { font-family: var(--font-title); font-size: 4.3rem; color: #222; line-height: 1.3; } code { font-family: var(--font-code); font-size: 1.8rem; display: inline-block; border: 2px solid var(--main-color); padding: 1em 2em; } #scroll-indicator { position: absolute; margin-left: auto; margin-right: auto; left: 0; right: 0; height: 50px; width: 30px; bottom: 40px; border: 2px solid var(--text-color); border-radius: 20px; opacity: .2; transition: opacity 1s ease; } #scroll-indicator:before { content: ''; position: absolute; top: 10px; left: 50%; width: 6px; height: 6px; margin-left: -3px; background-color: var(--text-color); border-radius: 100%; animation: scroll-down 2s infinite; } #scroll-indicator.hide { opacity: 0; } /* Section: Features */ .section-features-content { margin: 0 auto; max-width: 1040px; padding: 0 2em 10em; } .section-features-content-item { display: flex; padding: 5em 0 10em; } .section-features-column__image { position: relative; text-align: right; } .section-features-column__image:before { content: ''; display: block; width: 50%; height: 100px; position: absolute; left: 5em; top: 50%; margin-top: -50px; background: var(--main-color); z-index: -1; } .section-features-content-item:last-child .section-features-column__image:before { width: 60%; left: 0; } .section-features-content-item:last-child .section-features-column__text { text-align: right; } .section-features-content-item:last-child .section-feature-description { padding-right: 0; padding-left: 5em; } .section-features-column__image img { max-width: 85%; mix-blend-mode: darken; } .section-features-column__text { flex: 1; } .section-feature-title { font-size: 3rem; color: var(--text-color); margin: 0; padding: 1em 0 .8em; font-family: var(--font-title); } .section-feature-description { margin: 0; padding: 0; font-size: 1.6rem; color: #333; line-height: 2; padding-right: 5em; } .section-feature-description a { position: relative; display: inline-block; white-space: nowrap; text-decoration: none; color: inherit; padding: 0 2px; font-weight: bold; } .section-feature-description a:before { content: ''; position: absolute; left: 0; right: 0; width: 100%; height: 3px; bottom: 3px; background: var(--main-color); z-index: -1; transition: height .3s cubic-bezier(0.67, 0.04, 0, 1.21); } .section-feature-description a:hover:before { height: 78%; } /* Section: Get Started */ .section-started { background: var(--main-color); overflow: hidden; } .get-started-image { position: absolute; right: 0; top: 10em; max-width: 420px; mix-blend-mode: darken; transform: rotate(-15deg); } .section-started-content { position: relative; max-width: 1040px; margin: 0 auto; padding: 8em 2em 2em 2em; } .section-started-title { font-family: var(--font-title); font-size: 4.3rem; margin: 0; padding: 0 0 1.3em 0; } .section-started-subtitle { font-family: var(--font-title); font-size: 2.4rem; margin: 0; padding: 0 0 1em 0; } .started-steps { list-style: none; margin: 0; padding: 1em 0 5em 0; } .started-steps li { font-size: 1.8rem; margin-bottom: 1.4em; line-height: 1.6; } .started-steps li p { margin: 0 0 1.2em 0; padding: 0; } .started-steps li span { padding: 0 1em; } .started-steps li code { background: #fff; font-size: 1.6rem; padding: 1em 1.2em; margin-bottom: .5em; } /* Footer */ .footer { background: var(--text-color); padding: 4em 0; } .footer-content { position: relative; max-width: 1040px; margin: 0 auto; padding: 0 2em; } .footer-content p { color: #eee; margin: 0; padding: 0; font-size: 1.4rem; } .footer-content p a { color: inherit; text-decoration: none; padding-bottom: 2px; border-bottom: 2px solid #333; transition: border .5s ease; } .footer-content p a:hover { color: #fff; border-bottom-color: var(--main-color); } .footer-content p img { max-width: 18px; display: inline-block; vertical-align: middle; margin: -3px .3em 0; } .footer-image { position: absolute; max-width: 80px; top: -.8em; right: 2em; } /* Breakpoints */ @media (max-width: 1200px) { .header-menu { padding-right: 10em; } } @media (max-width: 800px) { .fork-button { display: none; } .header-menu { padding-right: 0; } .section-features-content { padding-bottom: 0; } .section-features-content-item { flex-direction: column; } .section-features-content-item:first-child { flex-direction: column-reverse; } .section-features-column__image { text-align: left; } .section-features-column__image img { max-width: 100%; } .section-features-column__image:before { left: 0; } .section-feature-description { padding-right: 1em; } .section-features-content-item:last-child .section-features-column__text { text-align: left; } .section-features-content-item:last-child .section-feature-description { padding-left: 0; padding-right: 1em; } } @media (max-width: 580px) { .header-menu, .get-started-image, #scroll-indicator { display: none; } .fork-button { display: block; top: 4em; right: -10em; font-size: 1em; font-weight: bold; padding: .7em 0; } .header { height: 550px; } .header-logo { margin-left: -5px; } .header-main-content { text-align: left; } .header-main-title { font-size: 3.5rem; } .section-started-content { padding-top: 6em; } } /* Animations */ @keyframes scroll-down { 0% { transform: translate(0, 0); opacity: 0; } 40% { opacity: 1; } 80% { transform: translate(0, 20px); opacity: 0; } 100% { opacity: 0; } } ================================================ FILE: docs/assets/favicons/browserconfig.xml ================================================ #ffc40d ================================================ FILE: docs/assets/favicons/site.webmanifest ================================================ { "name": "", "short_name": "", "icons": [ { "src": "android-chrome-192x192.png", "sizes": "192x192", "type": "image/png" }, { "src": "android-chrome-256x256.png", "sizes": "256x256", "type": "image/png" } ], "theme_color": "#ffffff", "background_color": "#ffffff", "display": "standalone" } ================================================ FILE: docs/index.html ================================================ Javali • Create a modern JavaScript library that uses ES6 + Jest
View on github

Create a modern JavaScript library that uses ES6 + Jest

npx javali my-lib

Simple, fast and efficient

Javali is a CLI similar to Create React App. With a simple command you can easily generate your JavaScript library. Without questions and complicated settings, you simply pass the name of your project and the magic happens.

Modern: ES6 and Jest

The generated library has all the newest features from the front-end development. You write ES6 and your library is compiled to ES5 (UMD and CJS). Besides that, the lib has Jest for tests, Rollup as bundler, Live Server to run locally and much more.

Get started

Using npx

  • 1. Install and create your library immediately:

    npx javali my-lib
  • 2. Enjoy

Using global cli

  • 1. Install Javali globally:

    yarn global add javali or npm install -g javali
  • 2. Create your library:

    javali my-lib
  • 3. Enjoy
================================================ FILE: license.md ================================================ # The MIT License (MIT) Copyright (c) 2019 – Diogo Moretti Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: package.json ================================================ { "name": "javali", "version": "1.1.0", "description": "Create a modern JavaScript library that uses ES6 + Jest", "main": "./cli/index.js", "bin": { "javali": "./cli/index.js" }, "scripts": { "site:server": "live-server ./docs --port=7001 -q --no-browser", "lint": "standard", "test": "jest" }, "jest": { "testPathIgnorePatterns": [ "/templates/" ] }, "keywords": [ "cli", "generator", "javascript", "library", "es6", "jest" ], "repository": { "type": "git", "url": "https://github.com/diogomoretti/javali" }, "standard": { "ignore": [ "/templates/", "/docs/", "/tests/" ] }, "author": "Diogo Moretti ", "license": "MIT", "devDependencies": { "jest": "^24.7.1", "live-server": "^1.2.1", "rimraf": "^2.6.3", "standard": "^12.0.1" }, "dependencies": { "chalk": "^2.4.2", "commander": "^2.19.0", "lodash": "^4.17.11", "recursive-readdir": "^2.2.2", "shelljs": "^0.8.3", "wrench": "^1.5.9" } } ================================================ FILE: readme.md ================================================

Javali

NPM JavaScript Style Guide

javali.js.org


## 🐗 About **[Javali](https://javali.js.org/)** (aka **JAVA***Script* **LI***brary*) is a CLI like [Create React App](https://github.com/facebook/create-react-app), but for creating JavaScript libraries. Below, some features: - **Simple command** to create a library - **Fully ES6** that compiles to UMD and CommonJS - **Supports Typescript** - **[Jest](https://jestjs.io/)** for tests - **[Rollup](https://rollupjs.org)** as bundler - **[Live Server](https://github.com/tapio/live-server)** to run locally
## 🐗 Get started ### Using `npx` **1** ⁓ Install and create your library immediately: ```shell npx javali my-lib ``` **2** ⁓ Enjoy! ### Using global cli **1** ⁓ Install **[Javali](https://javali.js.org/)** globally: ```shell yarn global add javali or npm install -g javali ``` **2** ⁓ Create your library: ```shell javali my-lib ``` Or using TypeScript: ```shell javali my-lib --typescript ``` **3** ⁓ Enjoy! ✅ A folder and library called `my-lib` will be created in this case.
## 🐗 Contributing 1. Fork this repository 2. `git checkout -b my-feature` 3. `git add --all` 4. `git commit -m "My commit message about my-feature"` 5. `git push origin my-feature` 6. Open a Pull Request =]
## 🐗 License [MIT](./license.md) © [Diogo Moretti](https://github.com/diogomoretti) ================================================ FILE: templates/js/_babelrc ================================================ { "presets": [ ["@babel/preset-env", { "modules": false, "targets": { "browsers": "ie >= 11" } }] ], "env": { "test": { "presets": [["@babel/preset-env"]] } } } ================================================ FILE: templates/js/_editorconfig ================================================ root = true [*] charset = utf-8 indent_style = space indent_size = 2 end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true ================================================ FILE: templates/js/_gitignore ================================================ node_modules/ dist/ npm-debug.log yarn-error.log package-lock.json ================================================ FILE: templates/js/_npmrc ================================================ package-lock=false ================================================ FILE: templates/js/_package ================================================ { "name": "{{= appName }}", "version": "0.1.0", "main": "dist/{{= appName }}.cjs.js", "module": "dist/{{= appName }}.esm.js", "browser": "dist/{{= appName }}.umd.js", "license": "MIT", "repository": { "type": "git", "url": "" }, "devDependencies": { "@babel/core": "7.4.0", "@babel/preset-env": "7.4.2", "babel-core": "7.0.0-bridge.0", "babel-jest": "24.5.0", "jest": "24.5.0", "live-server": "^1.2.1", "rollup": "1.7.0", "rollup-plugin-babel": "4.3.2", "rollup-plugin-commonjs": "9.2.1", "rollup-plugin-node-resolve": "4.0.1", "concurrently": "^4.1.0" }, "scripts": { "prepare": "{{= appCmd }} build", "build": "rollup -c", "watch": "rollup -c -w", "server": "live-server --port=7000 -q --open=./example", "start": "concurrently \"{{= appManager }}:watch\" \"{{= appManager }}:server\"", "test": "jest" }, "files": [ "dist" ] } ================================================ FILE: templates/js/example/index.html ================================================ {{= appName }}
================================================ FILE: templates/js/license.md ================================================ The MIT License (MIT) Copyright (c) 2019 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: templates/js/readme.md ================================================ # 🐗 {{= appName }} > My awesome lib created by [Javali](https://javali.js.org) ================================================ FILE: templates/js/rollup.config.js ================================================ import resolve from 'rollup-plugin-node-resolve' import commonjs from 'rollup-plugin-commonjs' import pkg from './package.json' import babel from 'rollup-plugin-babel' export default [ { input: 'src/main.js', output: { name: 'index', file: pkg.browser, format: 'umd' }, plugins: [ resolve(), commonjs(), babel({ exclude: 'node_modules/**' }) ] }, { input: 'src/main.js', external: [], output: [ { file: pkg.main, format: 'cjs' }, { file: pkg.module, format: 'es' } ] } ] ================================================ FILE: templates/js/src/main.js ================================================ import myLibrary from './my-library' const myLib = new myLibrary('#root') ================================================ FILE: templates/js/src/my-library.js ================================================ class myLibrary { constructor (trigger) { this.trigger = trigger this.renderDiv() this.listenClick() } renderDiv () { const div = document.querySelector(this.trigger) div.innerHTML = `
0
` } updateCounter () { const div = document.getElementById('counter') div.innerHTML = parseInt(div.innerHTML) + 1 } listenClick () { const btn = document.getElementById('btn') btn.addEventListener('click', this.updateCounter) } } export default myLibrary ================================================ FILE: templates/js/src/my-library.test.js ================================================ import myLibrary from './my-library' document.body.innerHTML = '
' describe('myLibrary', () => { it('render library wrapper inside trigger div', () => { const myLib = new myLibrary('#root') expect(document.body.innerHTML).toBe('
0
') }) it('start counter with 0', () => { const myLib = new myLibrary('#root') const counter = document.getElementById('counter').innerHTML expect(parseInt(counter)).toBe(0) }) it('when click on button, counter is 1', () => { const myLib = new myLibrary('#root') myLib.updateCounter() const counter = document.getElementById('counter').innerHTML expect(parseInt(counter)).toBe(1) }) }) ================================================ FILE: templates/ts/_babelrc ================================================ { "presets": [ ["@babel/preset-env", { "modules": false, "targets": { "browsers": "ie >= 11" } }], "@babel/preset-typescript" ], "env": { "test": { "presets": [["@babel/preset-env"]] } } } ================================================ FILE: templates/ts/_editorconfig ================================================ root = true [*] charset = utf-8 indent_style = space indent_size = 2 end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true ================================================ FILE: templates/ts/_gitignore ================================================ node_modules/ dist/ npm-debug.log yarn-error.log package-lock.json ================================================ FILE: templates/ts/_npmrc ================================================ package-lock=false ================================================ FILE: templates/ts/_package ================================================ { "name": "{{= appName }}", "version": "0.1.0", "main": "dist/{{= appName }}.cjs.js", "types": "dist/{{= appName }}.d.ts", "module": "dist/{{= appName }}.esm.js", "browser": "dist/{{= appName }}.umd.js", "license": "MIT", "repository": { "type": "git", "url": "" }, "devDependencies": { "@babel/core": "7.4.0", "@babel/preset-env": "7.4.2", "@babel/preset-typescript": "7.3.3", "@types/jest": "24.0.11", "babel-core": "7.0.0-bridge.0", "babel-jest": "24.5.0", "jest": "24.5.0", "live-server": "^1.2.1", "rollup": "1.7.0", "rollup-plugin-babel": "4.3.2", "rollup-plugin-commonjs": "9.2.1", "rollup-plugin-node-resolve": "4.0.1", "concurrently": "^4.1.0" }, "scripts": { "prepare": "{{= appCmd }} build", "build": "rollup -c && yarn build:types", "watch": "rollup -c -w", "server": "live-server --port=7000 -q --open=./example", "start": "concurrently \"{{= appManager }}:watch\" \"{{= appManager }}:server\"", "test": "jest", "build:types": "tsc -p tsconfig.app.json --emitDeclarationOnly" }, "files": [ "dist" ], "dependencies": { "typescript": "^3.3.4000" } } ================================================ FILE: templates/ts/example/index.html ================================================ {{= appName }}
================================================ FILE: templates/ts/license.md ================================================ The MIT License (MIT) Copyright (c) 2019 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: templates/ts/readme.md ================================================ # 🐗 {{= appName }} > My awesome lib created by [Javali](https://javali.js.org) ================================================ FILE: templates/ts/rollup.config.js ================================================ import resolve from 'rollup-plugin-node-resolve' import commonjs from 'rollup-plugin-commonjs' import pkg from './package.json' import babel from 'rollup-plugin-babel' const plugins = [ resolve({ extensions: ['.js', '.ts'] }), commonjs(), babel({ exclude: 'node_modules/**', extensions: ['.js', '.ts'] }) ] export default [ { input: 'src/main.ts', output: { name: 'index', file: pkg.browser, format: 'umd' }, plugins }, { input: 'src/main.ts', external: [], output: [ { file: pkg.main, format: 'cjs' }, { file: pkg.module, format: 'es' } ], plugins } ] ================================================ FILE: templates/ts/src/main.ts ================================================ import myLibrary from './my-library' const myLib = new myLibrary('#root') ================================================ FILE: templates/ts/src/my-library.test.ts ================================================ import myLibrary from './my-library' document.body.innerHTML = '
' describe('myLibrary', () => { it('render library wrapper inside trigger div', () => { const myLib = new myLibrary('#root') expect(document.body.innerHTML).toBe('
0
') }) it('start counter with 0', () => { const myLib = new myLibrary('#root') const counter = document.getElementById('counter').innerHTML expect(parseInt(counter)).toBe(0) }) it('when click on button, counter is 1', () => { const myLib = new myLibrary('#root') myLib.updateCounter() const counter = document.getElementById('counter').innerHTML expect(parseInt(counter)).toBe(1) }) }) ================================================ FILE: templates/ts/src/my-library.ts ================================================ class myLibrary { trigger: string; constructor (trigger: string) { this.trigger = trigger this.renderDiv() this.listenClick() } renderDiv () { const div = document.querySelector(this.trigger) div!.innerHTML = `
0
` } updateCounter () { const div = document.getElementById('counter') div!.innerHTML = `${parseInt(div!.innerHTML) + 1}` } listenClick () { const btn = document.getElementById('btn') btn!.addEventListener('click', this.updateCounter) } } export default myLibrary ================================================ FILE: templates/ts/tsconfig.app.json ================================================ { "extends": "./tsconfig.json", "exclude": ["**/*.test.ts"] } ================================================ FILE: templates/ts/tsconfig.json ================================================ { "include": ["src"], "compilerOptions": { /* Basic Options */ "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' 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": true, /* 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. */ "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ // "sourceMap": true, /* Generates corresponding '.map' file. */ // "outFile": "./", /* Concatenate and emit output to single file. */ "outDir": "./dist", /* Redirect output structure to the directory. */ // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ // "composite": true, /* Enable project compilation */ // "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": true, /* 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. */ // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ // "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. */ "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ // "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. */ } } ================================================ FILE: tests/index.test.js ================================================ const fs = require('fs') const path = require('path') const rimraf = require('rimraf') const exec = require('child_process').exec const TEMP_FOLDER = '__temp__' beforeAll(() => { if (!fs.existsSync(TEMP_FOLDER)) { fs.mkdirSync(TEMP_FOLDER) } }) test('Run Javali cli without errors', async () => { const result = await cli('my-library', TEMP_FOLDER) expect(result.code).toBe(0) }) test('Create a library called "my-library"', async () => { await cli('my-library', TEMP_FOLDER) const folderExists = fs.existsSync(`${TEMP_FOLDER}/my-library`) expect(folderExists).toBe(true) }) test('Create a library called "my-library-with-typescript" with Typescript', async () => { await cli('my-library-with-typescript --typescript', TEMP_FOLDER) const fileExists = fs.existsSync(`${TEMP_FOLDER}/my-library-with-typescript/tsconfig.json`) expect(fileExists).toBe(true) }) afterAll(() => { rimraf.sync(TEMP_FOLDER) }) function cli (args, cwd) { return new Promise(resolve => { exec(`node ${path.resolve('./cli/index')} ${args}`, { cwd }, (error, stdout, stderr) => { resolve({ code: error && error.code ? error.code : 0, error, stdout, stderr }) }) }) }