Skip to content

Commit

Permalink
chore: fix sync-readmes running on node 6
Browse files Browse the repository at this point in the history
  • Loading branch information
MarshallOfSound committed Jul 4, 2018
1 parent 4466904 commit 1961338
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"docs": "bolt docs:generate && bolt docs:position",
"docs:generate": "bolt ws exec -- node_modules/.bin/typedoc --out doc --excludeExternals --ignoreCompilerErrors --mode file --excludePrivate --excludeProtected --hideGenerator",
"docs:position": "ts-node tools/position-docs.ts",
"docs:deploy": "node tools/sync-readmes.js && bolt docs && ts-node tools/copy-now.ts && cd docs && now && now alias",
"docs:deploy": "ts-node tools/sync-readmes.ts && bolt docs && ts-node tools/copy-now.ts && cd docs && now && now alias",
"lint": "ts-node tools/link-ts.ts && bolt ws exec -- node_modules/.bin/tslint src/**/*.ts test/**/*.ts",
"test": "bolt ws run test"
},
Expand Down Expand Up @@ -105,6 +105,7 @@
"@types/glob": "^5.0.35",
"@types/html-webpack-plugin": "^2.30.3",
"@types/inquirer": "^0.0.41",
"@types/listr": "^0.13.0",
"@types/lodash.merge": "^4.6.3",
"@types/lodash.template": "^4.4.3",
"@types/log-symbols": "^2.0.0",
Expand Down
1 change: 1 addition & 0 deletions tools/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const fs = require('fs-extra');
const path = require('path');
const spawnPromise = require('cross-spawn-promise');
const Listr = require('listr');
require('ts-node').register();

const BASE_DIR = path.resolve(__dirname, '..');
const PACKAGES_DIR = path.resolve(BASE_DIR, 'packages');
Expand Down
22 changes: 13 additions & 9 deletions tools/sync-readmes.js → tools/sync-readmes.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const fetch = require('node-fetch');
const fs = require('fs-extra');
const Listr = require('listr');
const path = require('path');
import fetch from 'node-fetch';
import * as fs from 'fs-extra';
import Listr from 'listr';
import * as path from 'path';

const workspaceMappings = {
const workspaceMappings: { [space: string]: { [packageName: string]: string | undefined }} = {
maker: {
wix: 'wix-msi',
squirrel: 'squirrel.windows',
Expand All @@ -16,15 +16,15 @@ const workspaceMappings = {
const BASE_DIR = path.resolve(__dirname, '..');
const DOCS_BASE = 'https://raw.githubusercontent.com/MarshallOfSound/electron-forge-docs/v6';

const sanitize = (gb) => {
const sanitize = (gb: string) => {
return gb
.replace('{% code-tabs %}', '')
.replace('{% endcode-tabs %}', '')
.replace(/{% code-tabs-item title=".+?" %}/g, '')
.replace('{% endcode-tabs-item %}', '')
.replace('{% endhint %}', '\n--------')
.replace(/{% hint style="(.+?)" %}\n/g, (_, style) => {
const styleMap = {
const styleMap: { [style: string]: string | undefined } = {
warning: '⚠️',
info: 'ℹ️',
danger: '🚨',
Expand All @@ -33,11 +33,15 @@ const sanitize = (gb) => {
});
};

interface SyncContext {
packageKeys: [string, string, string, string][];
}

const sync = () => {
return new Listr([
{
title: 'Collecting package keys',
task: async (ctx) => {
task: async (ctx: SyncContext) => {
ctx.packageKeys = [];

for (const workspace of Object.keys(workspaceMappings)) {
Expand All @@ -53,7 +57,7 @@ const sync = () => {
},
{
title: 'Fetching READMEs',
task: (ctx) => new Listr(ctx.packageKeys.map(([workspace, workspaceDir, packageKey, packageName]) => ({
task: (ctx: SyncContext) => new Listr(ctx.packageKeys.map(([workspace, workspaceDir, packageKey, packageName]) => ({
title: `Fetching README for ${path.basename(workspaceDir)}/${packageKey}`,
task: async () => {
const r = await fetch(`${DOCS_BASE}/${workspace}s/${packageKey}.md`);
Expand Down
6 changes: 6 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,12 @@
"@types/rx" "*"
"@types/through" "*"

"@types/listr@^0.13.0":
version "0.13.0"
resolved "https://registry.yarnpkg.com/@types/listr/-/listr-0.13.0.tgz#6250bc4a04123cafa24fc73d1b880653a6ae6721"
dependencies:
"@types/node" "*"

"@types/lodash.merge@^4.6.3":
version "4.6.3"
resolved "https://registry.yarnpkg.com/@types/lodash.merge/-/lodash.merge-4.6.3.tgz#a41c49fe404c4bfb653ae6dda76abeedeace14ff"
Expand Down

0 comments on commit 1961338

Please sign in to comment.