Compare commits

...

9 Commits

Author SHA1 Message Date
Samy Pessé da2ee396cf Bump version to 4.0.0-alpha.4 🚀 2017-01-27 18:56:38 +01:00
Samy Pessé 2e66333aa6 Use less restrictive versions range for markup-it 2017-01-27 18:17:37 +01:00
Samy Pessé a2ad586a93 🆙 Update markup-it@3.2.2 2017-01-24 15:57:55 +01:00
Samy Pessé 856b222a61 Bump version to 4.0.0-alpha.3 🚀 2017-01-13 19:11:15 +01:00
Samy Pessé fade3740c1 Fix publish script 2017-01-13 19:10:49 +01:00
Samy Pessé 803d6218a7 Remove bump script from bootstrapping 2017-01-13 19:03:48 +01:00
Nicolas Gaborit 7128db842a Test and fix conversion of empty parts (#1675)
* Test and fix conversion of empty parts

* Cover case of last part empty
2017-01-13 18:56:32 +01:00
Nicolas Gaborit 0342a11da0 Fix and test Book.getDefaultExt() (#1674) 2017-01-13 17:55:22 +01:00
Samy Pessé af80cbcd7c Add script to publish a new version 2017-01-13 16:18:28 +01:00
24 changed files with 349 additions and 96 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
{
"lerna": "2.0.0-beta.31",
"version": "4.0.0-alpha.2"
"version": "4.0.0-alpha.4"
}
+3 -3
View File
@@ -8,10 +8,10 @@
"scripts": {
"lint": "eslint .",
"test": "lerna run --concurrency 1 test",
"bootstrap": "npm run bump && lerna bootstrap",
"bump": "./scripts/bump.js",
"bootstrap": "lerna bootstrap",
"clean": "lerna clean",
"dist": "lerna run --concurrency 1 prepublish"
"dist": "lerna run --concurrency 1 prepublish",
"publish-version": "./scripts/publish.sh"
},
"repository": {
"type": "git",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "gitbook-core",
"version": "4.0.0-alpha.2",
"version": "4.0.0-alpha.4",
"description": "Core for GitBook plugins API",
"main": "./lib/index.js",
"dependencies": {
@@ -3,13 +3,13 @@
"description": "Button to copy code blocks",
"main": "index.js",
"browser": "./_assets/plugin.js",
"version": "4.0.0-alpha.2",
"version": "4.0.0-alpha.4",
"dependencies": {
"copy-to-clipboard": "^3.0.5",
"gitbook-core": "^4.0.0-alpha.2"
"gitbook-core": "^4.0.0-alpha.4"
},
"devDependencies": {
"gitbook-plugin": "^4.0.0-alpha.2"
"gitbook-plugin": "^4.0.0-alpha.4"
},
"engines": {
"gitbook": ">=3.0.0"
@@ -3,13 +3,13 @@
"description": "Automatically add anchors to headings",
"main": "index.js",
"browser": "./_assets/plugin.js",
"version": "4.0.0-alpha.2",
"version": "4.0.0-alpha.4",
"dependencies": {
"classnames": "^2.2.5",
"gitbook-core": "^4.0.0-alpha.2"
"gitbook-core": "^4.0.0-alpha.4"
},
"devDependencies": {
"gitbook-plugin": "^4.0.0-alpha.2"
"gitbook-plugin": "^4.0.0-alpha.4"
},
"engines": {
"gitbook": ">=3.0.0"
@@ -3,13 +3,13 @@
"description": "Syntax highlighter for Gitbook",
"main": "index.js",
"browser": "./_assets/plugin.js",
"version": "4.0.0-alpha.2",
"version": "4.0.0-alpha.4",
"dependencies": {
"gitbook-core": "^4.0.0-alpha.2",
"gitbook-core": "^4.0.0-alpha.4",
"highlight.js": "9.7.0"
},
"devDependencies": {
"gitbook-plugin": "^4.0.0-alpha.2"
"gitbook-plugin": "^4.0.0-alpha.4"
},
"engines": {
"gitbook": ">=3.0.0"
+3 -3
View File
@@ -3,13 +3,13 @@
"description": "Defines four types of styled hint blocks: info, danger, tip, working.",
"main": "index.js",
"browser": "./_assets/plugin.js",
"version": "4.0.0-alpha.2",
"version": "4.0.0-alpha.4",
"dependencies": {
"classnames": "^2.2.5",
"gitbook-core": "^4.0.0-alpha.2"
"gitbook-core": "^4.0.0-alpha.4"
},
"devDependencies": {
"gitbook-plugin": "^4.0.0-alpha.2"
"gitbook-plugin": "^4.0.0-alpha.4"
},
"engines": {
"gitbook": ">=4.0.0"
@@ -3,15 +3,15 @@
"description": "Live reloading for your gitbook",
"main": "index.js",
"browser": "./_assets/plugin.js",
"version": "4.0.0-alpha.2",
"version": "4.0.0-alpha.4",
"engines": {
"gitbook": "*"
},
"dependencies": {
"gitbook-core": "^4.0.0-alpha.2"
"gitbook-core": "^4.0.0-alpha.4"
},
"devDependencies": {
"gitbook-plugin": "^4.0.0-alpha.2"
"gitbook-plugin": "^4.0.0-alpha.4"
},
"scripts": {
"build-js": "gitbook-plugin build ./src/index.js ./_assets/plugin.js",
+3 -3
View File
@@ -3,14 +3,14 @@
"description": "Static and local index for search in GitBook",
"main": "index.js",
"browser": "./_assets/theme.js",
"version": "4.0.0-alpha.2",
"version": "4.0.0-alpha.4",
"dependencies": {
"gitbook-core": "^4.0.0-alpha.2",
"gitbook-core": "^4.0.0-alpha.4",
"html-entities": "1.2.0",
"lunr": "0.5.12"
},
"devDependencies": {
"gitbook-plugin": "^4.0.0-alpha.2"
"gitbook-plugin": "^4.0.0-alpha.4"
},
"engines": {
"gitbook": ">=3.0.0"
+3 -3
View File
@@ -3,13 +3,13 @@
"description": "Search integration in GitBook",
"main": "index.js",
"browser": "./_assets/theme.js",
"version": "4.0.0-alpha.2",
"version": "4.0.0-alpha.4",
"dependencies": {
"gitbook-core": "^4.0.0-alpha.2",
"gitbook-core": "^4.0.0-alpha.4",
"react": "^15.4.1"
},
"devDependencies": {
"gitbook-plugin": "^4.0.0-alpha.2",
"gitbook-plugin": "^4.0.0-alpha.4",
"react-highlighter": "^0.3.3"
},
"engines": {
+3 -3
View File
@@ -3,7 +3,7 @@
"description": "Sharing buttons in the toolbar",
"main": "index.js",
"browser": "./_assets/plugin.js",
"version": "4.0.0-alpha.2",
"version": "4.0.0-alpha.4",
"gitbook": {
"properties": {
"facebook": {
@@ -53,10 +53,10 @@
}
},
"dependencies": {
"gitbook-core": "^4.0.0-alpha.2"
"gitbook-core": "^4.0.0-alpha.4"
},
"devDependencies": {
"gitbook-plugin": "^4.0.0-alpha.2"
"gitbook-plugin": "^4.0.0-alpha.4"
},
"engines": {
"gitbook": ">=3.0.0"
@@ -3,19 +3,19 @@
"description": "Default theme for GitBook",
"main": "./index.js",
"browser": "./_assets/theme.js",
"version": "4.0.0-alpha.2",
"version": "4.0.0-alpha.4",
"engines": {
"gitbook": ">=3.0.0"
},
"dependencies": {
"debounce": "^1.0.0",
"gitbook-core": "^4.0.0-alpha.2"
"gitbook-core": "^4.0.0-alpha.4"
},
"devDependencies": {
"classnames": "^2.2.5",
"font-awesome": "^4.6.3",
"gitbook-markdown-css": "^1.0.1",
"gitbook-plugin": "^4.0.0-alpha.2",
"gitbook-plugin": "^4.0.0-alpha.4",
"less": "^2.7.1",
"less-plugin-clean-css": "^1.5.1",
"preboot": "git+https://github.com/mdo/preboot.git#4aab4edd85f076d50609cbe28e4fe66cc0771701"
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "gitbook-plugin",
"version": "4.0.0-alpha.2",
"version": "4.0.0-alpha.4",
"description": "CLI for compiling and testing plugins",
"main": "./lib/index.js",
"dependencies": {
+12 -12
View File
@@ -1,6 +1,6 @@
{
"name": "gitbook",
"version": "4.0.0-alpha.2",
"version": "4.0.0-alpha.4",
"homepage": "https://www.gitbook.com",
"description": "Library and cmd utility to generate GitBooks",
"main": "lib/index.js",
@@ -22,16 +22,16 @@
"extend": "^3.0.0",
"fresh-require": "1.0.3",
"front-matter": "^2.1.0",
"gitbook-core": "^4.0.0-alpha.2",
"gitbook-plugin-copy-code": "^4.0.0-alpha.2",
"gitbook-plugin-headings": "^4.0.0-alpha.2",
"gitbook-plugin-highlight": "^4.0.0-alpha.2",
"gitbook-plugin-hints": "^4.0.0-alpha.2",
"gitbook-plugin-livereload": "^4.0.0-alpha.2",
"gitbook-plugin-lunr": "^4.0.0-alpha.2",
"gitbook-plugin-search": "^4.0.0-alpha.2",
"gitbook-plugin-sharing": "^4.0.0-alpha.2",
"gitbook-plugin-theme-default": "^4.0.0-alpha.2",
"gitbook-core": "^4.0.0-alpha.4",
"gitbook-plugin-copy-code": "^4.0.0-alpha.4",
"gitbook-plugin-headings": "^4.0.0-alpha.4",
"gitbook-plugin-highlight": "^4.0.0-alpha.4",
"gitbook-plugin-hints": "^4.0.0-alpha.4",
"gitbook-plugin-livereload": "^4.0.0-alpha.4",
"gitbook-plugin-lunr": "^4.0.0-alpha.4",
"gitbook-plugin-search": "^4.0.0-alpha.4",
"gitbook-plugin-sharing": "^4.0.0-alpha.4",
"gitbook-plugin-theme-default": "^4.0.0-alpha.4",
"github-slugid": "1.0.1",
"graceful-fs": "4.1.4",
"i18n-t": "1.0.1",
@@ -43,7 +43,7 @@
"json-schema-defaults": "0.1.1",
"jsonschema": "1.1.0",
"juice": "2.0.0",
"markup-it": "3.3.0",
"markup-it": "^3.2.2",
"mkdirp": "0.5.1",
"moment": "2.13.0",
"npm": "3.10.9",
@@ -0,0 +1,65 @@
const Book = require('../book');
const File = require('../file');
const Readme = require('../readme');
const Summary = require('../summary');
const Glossary = require('../glossary');
function createMockBook(def) {
return new Book({
readme: new Readme({
file: new File({ path: def.readme })
}),
summary: new Summary({
file: new File({ path: def.summary })
}),
glossary: new Glossary({
file: new File({ path: def.glossary })
})
});
}
describe('Book', () => {
describe('getDefaultExt', () => {
it('must infer from README', () => {
const book = createMockBook({
readme: 'README.adoc',
summary: 'SUMMARY.md',
glossary: 'GLOSSARY.md'
});
expect(book.getDefaultExt()).toBe('.adoc');
});
it('must infer from SUMMARY', () => {
const book = createMockBook({
readme: '',
summary: 'SUMMARY.adoc',
glossary: 'GLOSSARY.md'
});
expect(book.getDefaultExt()).toBe('.adoc');
});
it('must infer from GLOSSARY', () => {
const book = createMockBook({
readme: '',
summary: '',
glossary: 'GLOSSARY.adoc'
});
expect(book.getDefaultExt()).toBe('.adoc');
});
it('must default to .md', () => {
const book = createMockBook({
readme: '',
summary: '',
glossary: ''
});
expect(book.getDefaultExt()).toBe('.md');
});
});
});
+1 -1
View File
@@ -259,7 +259,7 @@ class Book extends Record(DEFAULTS) {
const exts = clues.map((clue) => {
const file = clue.getFile();
if (file.exists()) {
return file.getParser().getExtensions().first();
return file.getParser().FILE_EXTENSIONS[0];
} else {
return null;
}
@@ -0,0 +1,58 @@
nodes:
- kind: block
type: header_one
nodes:
- kind: text
text: Summary
- kind: block
type: header_two
nodes:
- kind: text
text: 'Part 1'
- kind: block
type: unordered_list
nodes:
- kind: block
type: list_item
nodes:
- kind: block
type: unstyled
nodes:
- kind: text
text: 'Article 1'
- kind: block
type: header_two
nodes:
- kind: text
text: 'Empty part 1'
- kind: block
type: header_two
nodes:
- kind: text
text: 'Empty part 2'
- kind: block
type: header_two
nodes:
- kind: text
text: 'Part 2'
- kind: block
type: unordered_list
nodes:
- kind: block
type: list_item
nodes:
- kind: block
type: unstyled
nodes:
- kind: text
text: 'Article 2'
- kind: block
type: header_two
nodes:
- kind: text
text: 'Empty part 3'
@@ -106,6 +106,39 @@ describe('summaryToDocument', () => {
]);
});
it('should convert empty parts', () => {
expectDocument('empty-part.yaml', [
{
title: 'Part 1',
articles: [
{
title: 'Article 1'
}
]
},
{
title: 'Empty part 1',
articles: []
},
{
title: 'Empty part 2',
articles: []
},
{
title: 'Part 2',
articles: [
{
title: 'Article 2'
}
]
},
{
title: 'Empty part 3',
articles: []
}
]);
});
it('should convert a deep summary', () => {
expectDocument('deep.yaml', [
{
@@ -85,7 +85,9 @@ function summaryToDocument(summary) {
}));
}
nodes.push(articlesToBlock(articles));
if (!articles.isEmpty()) {
nodes.push(articlesToBlock(articles));
}
});
return Document.create({ nodes });
@@ -0,0 +1,58 @@
nodes:
- kind: block
type: header_one
nodes:
- kind: text
text: Summary
- kind: block
type: header_two
nodes:
- kind: text
text: 'Part 1'
- kind: block
type: unordered_list
nodes:
- kind: block
type: list_item
nodes:
- kind: block
type: unstyled
nodes:
- kind: text
text: 'Article 1'
- kind: block
type: header_two
nodes:
- kind: text
text: 'Empty part 1'
- kind: block
type: header_two
nodes:
- kind: text
text: 'Empty part 2'
- kind: block
type: header_two
nodes:
- kind: text
text: 'Part 2'
- kind: block
type: unordered_list
nodes:
- kind: block
type: list_item
nodes:
- kind: block
type: unstyled
nodes:
- kind: text
text: 'Article 2'
- kind: block
type: header_two
nodes:
- kind: text
text: 'Empty part 3'
@@ -112,6 +112,41 @@ describe('summaryFromDocument', () => {
]);
});
it('should parse empty parts', () => {
const summary = readSummary('summary/empty-part.yaml');
expectParts(summary, [
{
title: 'Part 1',
articles: [
{
title: 'Article 1'
}
]
},
{
title: 'Empty part 1',
articles: []
},
{
title: 'Empty part 2',
articles: []
},
{
title: 'Part 2',
articles: [
{
title: 'Article 2'
}
]
},
{
title: 'Empty part 3',
articles: []
}
]);
});
it('should parse an deep summary', () => {
const summary = readSummary('summary/deep.yaml');
@@ -46,7 +46,9 @@ function listArticles(list) {
function listParts(document) {
const { nodes } = document;
const parts = [];
let title = '';
// Keep a reference to a part, waiting for its articles
let pendingPart;
nodes.forEach((node) => {
const isHeading = (
@@ -55,20 +57,36 @@ function listParts(document) {
);
if (isHeading) {
title = node.text;
if (pendingPart) {
// The previous was empty
parts.push(pendingPart);
}
pendingPart = {
title: node.text
};
}
if (isList(node)) {
const articles = listArticles(node);
parts.push({
title,
articles
});
title = '';
if (pendingPart) {
pendingPart.articles = articles;
parts.push(pendingPart);
pendingPart = undefined;
} else {
parts.push({
title: '',
articles
});
}
}
});
if (pendingPart) {
// The last one was empty
parts.push(pendingPart);
}
return List(parts);
}
-42
View File
@@ -1,42 +0,0 @@
#! /usr/bin/env node
const fs = require('fs');
const path = require('path');
const lernaConfig = require('../lerna.json');
// List all the packages
const PACKAGES_DIR = path.resolve(__dirname, '../packages');
const packages = fs.readdirSync(PACKAGES_DIR);
function updateDependencies(dependencies) {
if (!dependencies) {
return;
}
Object.keys(dependencies).map((key) => {
if (!packages.includes(key)) {
return;
}
dependencies[key] = lernaConfig.version;
});
}
packages.forEach((name) => {
// Avoid .DS_Store
if (name[0] === '.') {
return;
}
const pkgPath = path.resolve(PACKAGES_DIR, name, 'package.json');
const pkg = require(pkgPath);
pkg.version = lernaConfig.version;
updateDependencies(pkg.dependencies);
updateDependencies(pkg.devDependencies);
const json = JSON.stringify(pkg, null, 2);
fs.writeFileSync(pkgPath, `${json}\n`, 'utf-8');
});
+26
View File
@@ -0,0 +1,26 @@
#!/bin/bash
defaultTag=latest
echo ""
echo "You are trying to publish a new version of GitBook"
echo "⚠️ Currently, because of NPM access, this script can only be run by Samy"
echo ""
echo "Steps:"
echo " 1. Enter the new version"
echo " 2. Packages will be published on NPM"
echo " 3. Commit the changes with message 'Bump version to X 🚀 '"
echo " 4. Tag the commit"
echo " 5. Push"
echo ""
read -p "Version: " version
read -p "NPM Tag (latest or pre) [$defaultTag]:" tag
tag=${tag:-$defaultTag}
echo ""
echo "You are going to publish version ${version} on NPM (tagged as ${tag})"
echo "Press [ENTER] tp confirm"
read
lerna publish --skip-git --repo-version ${version} --npm-tag ${tag} --force-publish=*