Skip to content

Commit

Permalink
Merge pull request #11 from obstudio/dev
Browse files Browse the repository at this point in the history
Marklet v1.2
  • Loading branch information
jjyyxx authored Oct 6, 2018
2 parents 89b2dcd + 26556dd commit 100b125
Show file tree
Hide file tree
Showing 101 changed files with 3,052 additions and 1,507 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ test.*
dist
temp
!test
*.tgz
*.tgz
packages/app/main.js
packages/app/index.html
34 changes: 14 additions & 20 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
language: node_js

node_js:
- node

- node
env:
global:
- secure: ikFQOw+feac3+WhVb1QtCeAqp9OpQprD4oXmG4+q3MVAHFiP2pLcfZbrExr0bu472eEHLpRDjjlxHEGxcnJoSool4LUCkgTnlpN8/iGzug0gnv1/XoLZiwKVbonOQHaksJ8vGBIXFMPbXRYfc1DjSyWQhwxkdhrIGUEyPs0IqrBZ4nzbpCG/hsSbkKG6xMu5sXXwM/4Nmklx8kZRMWCQXB09gMysmt1TmPwxogyxXg1xm8GaSfA5GQHJZyW3oQpvGMKaXyDLymjLw66rlrUhZ9u0TKklkBqtVlhBnGm/eXxNFnDTfz+D8K3v2MSoSRuFb8bsofLHDFDm9suBuVV83nmINhkIcsmxEbS5B+Cv916za0NgCKxKJW/DRuCCoOdjRrXk36oC+7DCvEIVH8Hsraj7oC/WgBWSHCkI12UAXhxoSHrS3OiNxJEVZJXqIUzzzbyJJE5DTHElmBm1T6ZM7WEydzAPfhtzs/d5SsjwP0w6n+8SrnKifuBaFNw7wv40sdwey9TKJEXD84AeBsbTmJQCljJuKZntQryfoCVYB82OasEoEF0ryCnc0to1/lszXLAKJBv7gOTxzQ62tKo3wJo2L6FhGIOYG5n0NVXz7kC+5rKh5ZIwKx42oT9P4OAAwpM3p+LxzS7lkn6WLamFlioCFnzmvItO9yOFR/pIiKY=

- secure: iQS7C6BZcBlFCfj4a/1scDVO6qOCMCb2lYfZSTVS1QRnMns3wNBaDARXKrjl2LLzVPqz5puhj7+z7grUZ/rAUIAsAQUJtHqpTcpHY6kksQsh5yqNYgfwACAx0VNPicLEv2f/ekjabxaA1+7FhbCR+DFa/ZUuXGC+RpVm/EWhDDEkmGVHvXoJN92dW5lfPy/kJwpus03Mr+tPVbDJwO83sWhulUTxRuf1bEAg2/fUiPf+qZzRy6swEnfS7GlQrpD0/KHYGoa0Dt3TmqJ1oP03CRvdo/g45VZutonjLNAu7oJ/lrSTNLU68JGOnv+WCGL9RwPgfBcjTldxmSer4fwYLh+oj1IJHexNA2G0dStYVwKfkj8jEd7DLJxOrOdTYXovl3tRpyGN7oCDoWepvH1nYPBvZno9Kgt32VW/xwhqZgia5tmzra0ouyxJ/GzOXph2NaHTe9jzuF2/i814q1r3VfC5Wm3kai5R2RoNtv6bk9vS4QyEwum5JhQRJpO9O8/z393fTxMN1ZOC7D307eUQLPiLSjb/MkEfEuWtqvuEieYKs7UelC9SzrM83urJUc94FFhGfLuhqriLTJSd8gdlm5iBPjz6WrhW8n6JCa0t7iI90Cxn4DIr7KB7SROW66KSC8HPi9srPcJKVb1dx/Z8PMSP4y6ZmkTMXpbryTFK9Vo=
before_install:
- node ./build/check.js

- node ./build/check.js
install:
- npm i
- npm run bootstrap

- npm i
- npm run bootstrap
script:
- npm run lint
- npm run build:prod
- npm run test

- npm run lint
- npm run build:prod
- npm run test
deploy:
- skip_cleanup: true
provider: script
script: node ./build/release.js
on:
repo: obstudio/Marklet
branch: master
- skip_cleanup: true
provider: script
script: node ./build/release.js
on:
repo: obstudio/Marklet
branch: master
7 changes: 5 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
"request": "launch",
"name": "Debug Main Process",
"cwd": "${workspaceRoot}",
"runtimeExecutable": "npm",
"args": [ "start" ],
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
"windows": {
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
},
"args" : ["packages/app/main.dev.js"]
}
]
}
6 changes: 4 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
"vue"
],
"files.exclude": {
"**/node_modules": true,
"**/package-lock.json": true,
"package.json.lerna_backup": true,
"packages/**/node_modules": true,
// "packages/**/tsconfig.json": true
"packages/**/tsconfig.json": true,
"packages/**/dist": true,
"packages/**/temp": true,
},
"editor.wordSeparators": "`~!@#%^&*()-=+[{]}\\|;:'\",.<>/?",
}
38 changes: 34 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,53 @@
# Marklet

[![Build Status](https://travis-ci.com/obstudio/Marklet.svg?branch=dev)](https://travis-ci.com/obstudio/Marklet)
[![dependency](https://img.shields.io/david/obstudio/Marklet.svg)](https://github.com/obstudio/Marklet/blob/master/package.json)
[![npm](https://img.shields.io/npm/v/markletjs.svg)](https://www.npmjs.com/package/markletjs)
[![npm bundle size (minified)](https://img.shields.io/bundlephobia/min/markletjs.svg)](https://www.npmjs.com/package/markletjs)

A markup language designed for API manual pages.

## Node
## Packages

- [markletjs](https://github.com/obstudio/Marklet/tree/master/packages/marklet): [![npm](https://img.shields.io/npm/v/markletjs.svg)](https://www.npmjs.com/package/markletjs)
- [@marklet/cli](https://github.com/obstudio/Marklet/tree/master/packages/cli): [![npm](https://img.shields.io/npm/v/@marklet/cli.svg)](https://www.npmjs.com/package/@marklet/cli)
- [@marklet/core](https://github.com/obstudio/Marklet/tree/master/packages/core): [![npm](https://img.shields.io/npm/v/@marklet/core.svg)](https://www.npmjs.com/package/@marklet/core)
- [@marklet/dev-server](https://github.com/obstudio/Marklet/tree/master/packages/dev-server): [![npm](https://img.shields.io/npm/v/@marklet/dev-server.svg)](https://www.npmjs.com/package/@marklet/dev-server)
- [@marklet/monaco](https://github.com/obstudio/Marklet/tree/master/packages/monaco): [![npm](https://img.shields.io/npm/v/@marklet/monaco.svg)](https://www.npmjs.com/package/@marklet/monaco)
- [@marklet/parser](https://github.com/obstudio/Marklet/tree/master/packages/parser): [![npm](https://img.shields.io/npm/v/@marklet/parser.svg)](https://www.npmjs.com/package/@marklet/parser)
- [@marklet/renderer](https://github.com/obstudio/Marklet/tree/master/packages/renderer): [![npm](https://img.shields.io/npm/v/@marklet/renderer.svg)](https://www.npmjs.com/package/@marklet/renderer)

## Usage: CLI

```
Usage: marklet [filepath|dirpath] [options]
Options:
-v, --version output the version number
-m, --mode [mode] Choose between parse, watch and edit mode (default: parse)
-s, --source [path] Read text from file
-i, --input [text] Read text directly from stdin
-d, --dest [path] Write parsed data to file instead of stdin
-p, --port [port] Port for the development server
-l, --default-language [language] Default language in code block
-H, --no-header-align Disable header to align at center
-S, --no-section Disallow section syntax
-h, --help output usage information
```

## Usage: Node

```shell
npm i marklet
npm i markletjs
```

```javascript
```js
const Marklet = require('marklet')
Marklet.watch({ source: 'path/to/file' })
```

## Web
## Usage: Web

```html
<script src="marklet.dist.js"></script>
Expand Down
11 changes: 0 additions & 11 deletions build/clear.js

This file was deleted.

2 changes: 2 additions & 0 deletions build/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ program
.option('-1, --major')
.option('-2, --minor')
.option('-3, --patch')
.option('-o, --only')
.option('-p, --publish')
.parse(process.argv)

Expand All @@ -58,6 +59,7 @@ if (program.all) program.args = packageNames

function bump(name, flag) {
packages[name].bump(flag || 'patch')
if (program.only) return
const npmName = packages[name].current.name
packageNames.forEach((next) => {
if (npmName in (packages[next].current.devDependencies || {})) {
Expand Down
43 changes: 43 additions & 0 deletions build/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,51 @@ function resolve(...names) {
return path.join(__dirname, '../packages', ...names)
}

const timers = {}

function start(label = '') {
if (!timers[label]) timers[label] = { total: 0 }
timers[label].start = Date.now()
return _getTime(label)
}

function pause(label = '') {
timers[label].total += Date.now() - timers[label].start
timers[label].start = Date.now()
return _getTime(label)
}

function finish(label = '') {
pause(label)
const result = _getTime(label)
timers[label].total = 0
return `Finished in ${result.toFixed(1)}s.`
}

function _getTime(label = '') {
return label in timers ? timers[label].total / 1000 : 0
}

function timing(label = '', callback) {
start(label)
const result = callback()
pause(label)
return result
}

function isElectron() {
return typeof process !== 'undefined'
&& typeof process.versions !== 'undefined'
&& typeof process.versions.electron !== 'undefined'
}

module.exports = {
exec,
execSync,
resolve,
start,
pause,
finish,
timing,
isElectron,
}
23 changes: 11 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,40 +1,39 @@
{
"scripts": {
"start": "npm run build && node packages/cli -m edit",
"publish": "lerna publish --no-git-tag-version",
"bootstrap": "lerna bootstrap --hoist --no-ci",
"build": "tsc -b && node build/build -sr",
"build:prod": "tsc -b && node build/build -psr",
"build:renderer": "node build/build -r",
"build:server": "node build/build -s",
"build:tsc": "tsc -b",
"clear": "node build/clear",
"test": "node packages/test/runner.js",
"test": "node packages/test",
"lint": "tslint packages/**/src/*.ts && eslint ."
},
"devDependencies": {
"@octokit/rest": "^15.12.0",
"@octokit/rest": "^15.13.0",
"@sfc2js/clean-css": "^1.1.1",
"@sfc2js/sass": "^1.0.1",
"@types/cheerio": "^0.22.9",
"@types/js-yaml": "^3.11.2",
"@types/node": "^10.10.1",
"@types/node": "^10.11.4",
"@types/ws": "^6.0.1",
"ajv": "^6.5.3",
"ajv": "^6.5.4",
"chalk": "^2.4.1",
"cheerio": "^1.0.0-rc.2",
"commander": "^2.18.0",
"eslint": "^5.6.0",
"electron": "^3.0.2",
"eslint": "^5.6.1",
"eslint-plugin-vue": "^5.0.0-beta.3",
"fast-deep-equal": "^2.0.1",
"html-minifier": "^3.5.20",
"lerna": "^3.4.0",
"lerna": "^3.4.1",
"node-sass": "^4.9.3",
"prettier": "^1.14.3",
"sass": "^1.14.1",
"semver": "^5.5.1",
"sfc2js": "^3.3.0",
"sfc2js": "^3.3.2",
"tslint": "^5.11.0",
"typescript": "^3.0.3",
"webpack": "^4.19.1"
"typescript": "^3.1.1",
"webpack": "^4.20.2"
}
}
3 changes: 3 additions & 0 deletions packages/app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @marklet/app

An electron app for marklet.
68 changes: 68 additions & 0 deletions packages/app/build/transpile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
const util = require('../../../build/util')
const sfc2js = require('sfc2js')
const sass = require('sass')
const path = require('path')
const fs = require('fs')

util.start()

sfc2js.install({
name: 'sass-plugin',
version: '1.0',
target: 'style',
lang: [
'sass',
'scss',
'css',
],
default: {
includePaths: [],
},
updated(options) {
const dirPath = path.dirname(options.srcPath)
this.options.includePaths.push(dirPath)
},
render(style) {
return sass.renderSync({ ...this.options, data: style.content }).css.toString()
},
})

module.exports = sfc2js.transpile({
baseDir: util.resolve(),
srcDir: 'app/comp',
outDir: 'app/temp',
enterance: util.isElectron() ? 'app.vue' : '',
})

let indexCache = ''
try {
indexCache = fs.readFileSync(util.resolve('app/temp/index.cache.scss')).toString()
} catch (error) { /**/ }

const indexData = fs.readFileSync(util.resolve('app/comp/index.scss')).toString()

if (indexData === indexCache && fs.existsSync(util.resolve('app/temp/index.css'))) {
module.exports.css += fs.readFileSync(util.resolve('app/temp/index.css')).toString()
} else {
const indexCSS = sass.renderSync({ data: indexData }).css.toString()
fs.writeFileSync(util.resolve('app/temp/index.css'), indexCSS)
fs.writeFileSync(util.resolve('app/temp/index.cache.scss'), indexCache)
module.exports.css += indexCSS
}

if (util.isElectron()) {
const result = sfc2js.transpile({
baseDir: util.resolve(),
srcDir: 'renderer/comp',
outDir: 'renderer/temp',
enterance: '../src',
outCSSFile: '../dist/marklet.min.css',
defaultScript: {
props: ['node'],
},
})
module.exports.css += result.css
module.exports.plugin = result.app
}

console.log('Transpile Succeed.', util.finish())
5 changes: 5 additions & 0 deletions packages/app/comp/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
extends:
- plugin:vue/essential

globals:
Vue: true
Loading

0 comments on commit 100b125

Please sign in to comment.