From 196133886220c641cbb6ab5533fd54e878b3c4a0 Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Wed, 4 Jul 2018 12:55:41 +1000 Subject: [PATCH] chore: fix sync-readmes running on node 6 --- package.json | 3 ++- tools/publish.js | 1 + tools/{sync-readmes.js => sync-readmes.ts} | 22 +++++++++++++--------- yarn.lock | 6 ++++++ 4 files changed, 22 insertions(+), 10 deletions(-) rename tools/{sync-readmes.js => sync-readmes.ts} (76%) diff --git a/package.json b/package.json index 43bbcf1094..71f370515d 100644 --- a/package.json +++ b/package.json @@ -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" }, @@ -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", diff --git a/tools/publish.js b/tools/publish.js index 56e27b283a..fc9da30590 100644 --- a/tools/publish.js +++ b/tools/publish.js @@ -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'); diff --git a/tools/sync-readmes.js b/tools/sync-readmes.ts similarity index 76% rename from tools/sync-readmes.js rename to tools/sync-readmes.ts index d3d9f8ddb7..319617cc48 100644 --- a/tools/sync-readmes.js +++ b/tools/sync-readmes.ts @@ -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', @@ -16,7 +16,7 @@ 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 %}', '') @@ -24,7 +24,7 @@ const sanitize = (gb) => { .replace('{% endcode-tabs-item %}', '') .replace('{% endhint %}', '\n--------') .replace(/{% hint style="(.+?)" %}\n/g, (_, style) => { - const styleMap = { + const styleMap: { [style: string]: string | undefined } = { warning: '⚠️', info: 'ℹ️', danger: '🚨', @@ -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)) { @@ -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`); diff --git a/yarn.lock b/yarn.lock index 1c2f7f3cf1..679b95550d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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"