Skip to content

Commit

Permalink
Merge pull request #10 from obstudio/inline-lexer
Browse files Browse the repository at this point in the history
Inline lexer
  • Loading branch information
jjyyxx authored Sep 29, 2018
2 parents e0088b7 + a0ebf20 commit 89b2dcd
Show file tree
Hide file tree
Showing 27 changed files with 750 additions and 460 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"**/package-lock.json": true,
"package.json.lerna_backup": true,
"packages/**/node_modules": true,
"packages/**/tsconfig.json": true
// "packages/**/tsconfig.json": true
},
"editor.wordSeparators": "`~!@#%^&*()-=+[{]}\\|;:'\",.<>/?",
}
52 changes: 28 additions & 24 deletions build/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const chalk = require('chalk')
const semver = require('semver')
const cp = require('child_process')
const program = require('commander')
const { exec, execSync } = require('./util')
const { exec } = require('./util')

function toVersion(version) {
return `${version.major}.${version.minor}.${version.patch}`
Expand All @@ -13,12 +13,11 @@ function toVersion(version) {
class Package {
constructor(name) {
this.current = require(`../packages/${name}/package.json`)
this.previous = JSON.parse(cp.execSync(`git show HEAD:packages/${name}/package.json`).toString('utf8'))
this.previous = JSON.parse(cp.execSync(`git show HEAD:packages/${name}/package.json`).toString().trim())
this.major = semver.major(this.previous.version)
this.minor = semver.minor(this.previous.version)
this.patch = semver.patch(this.previous.version)
this.newVersion = this.current.version
delete this.current.gitHead
}

bump(flag) {
Expand Down Expand Up @@ -48,10 +47,10 @@ packageNames.forEach(name => packages[name] = new Package(name))
program
.usage('[options] [names...]')
.option('-a, --all')
.option('-M, --major')
.option('-m, --minor')
.option('-p, --patch')
.option('-N, --no-npm')
.option('-1, --major')
.option('-2, --minor')
.option('-3, --patch')
.option('-p, --publish')
.parse(process.argv)

const flag = program.major ? 'major' : program.minor ? 'minor' : 'patch'
Expand Down Expand Up @@ -83,25 +82,30 @@ ${chalk.cyanBright(packages[name].newVersion)}`)

let counter = 0, promise = Promise.resolve(), failed = false

if (program.npm) {
packageNames.forEach((name) => {
if (packages[name].newVersion !== packages[name].previous.version) {
if (packages[name].current.private) return
const npmVersion = execSync(`npm show ${packages[name].current.name} version`)
if (semver.gte(npmVersion, packages[name].newVersion)) return
counter += 1
fs.writeFileSync(
path.join(__dirname, `../packages/${name}/package.json`),
JSON.stringify(packages[name], null, 2),
)
promise = promise.then((code) => {
failed = failed || code
return exec(`cd packages/${name} && npm publish`)
})
}
})
if (program.publish) {
console.log('\nWaiting for packages to publish ...')
}

packageNames.forEach((name) => {
if (packages[name].newVersion !== packages[name].previous.version) {
fs.writeFileSync(
path.join(__dirname, `../packages/${name}/package.json`),
JSON.stringify(packages[name], null, 2),
)
if (packages[name].current.private || !program.publish) return
const npmVersion = cp.execSync(`npm show ${packages[name].current.name} version`).toString().trim()
if (semver.gte(npmVersion, packages[name].newVersion)) return
console.log(` - ${name} (${packages[name].current.name}): \
${chalk.green(npmVersion)} => \
${chalk.greenBright(packages[name].newVersion)}`)
counter += 1
promise = promise.then((code) => {
failed = failed || code
return exec(`cd packages/${name} && npm publish`)
})
}
})

promise.then(() => {
if (!counter) {
console.log('No packages to publish.')
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@marklet/cli",
"version": "1.1.4",
"version": "1.1.5",
"description": "A command line interface for marklet.",
"author": "jjyyxx <1449843302@qq.com>",
"contributors": [
Expand All @@ -19,8 +19,8 @@
"url": "https://github.com/obstudio/Marklet/issues"
},
"dependencies": {
"@marklet/dev-server": "^1.0.11",
"@marklet/parser": "^1.0.4",
"@marklet/dev-server": "^1.0.12",
"@marklet/parser": "^1.1.0",
"chalk": "^2.4.1",
"commander": "^2.18.0",
"js-yaml": "^3.12.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@marklet/core",
"version": "1.0.9",
"description": "A lexer for marklet.",
"version": "2.0.0",
"description": "Some core conceptions of marklet.",
"author": "shigma <1700011071@pku.edu.cn>",
"contributors": [
"jjyyxx <1449843302@qq.com>"
Expand Down
Loading

0 comments on commit 89b2dcd

Please sign in to comment.