Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade dependent packages to the latest version #130

Merged
merged 5 commits into from
Mar 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## [Unreleased]

### Changed

- Upgrade to [Marp Core v1.1.0](https://github.com/marp-team/marp-core/releases/v1.1.0) and [Marp CLI v0.17.3](https://github.com/marp-team/marp-cli/releases/v0.17.3) ([#130](https://github.com/marp-team/marp-vscode/pull/130))
- Upgrade dependent packages to the latest version ([#130](https://github.com/marp-team/marp-vscode/pull/130))

## v0.12.1 - 2020-02-23

### Fixed
Expand Down
32 changes: 18 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,7 @@
"private": true,
"prettier": {
"semi": false,
"singleQuote": true,
"trailingComma": "es5"
"singleQuote": true
},
"stylelint": {
"extends": [
Expand Down Expand Up @@ -211,9 +210,9 @@
"@rollup/plugin-commonjs": "^11.0.2",
"@rollup/plugin-json": "^4.0.2",
"@rollup/plugin-node-resolve": "^7.1.1",
"@rollup/plugin-typescript": "^3.0.0",
"@types/cheerio": "^0.22.16",
"@types/jest": "^25.1.3",
"@rollup/plugin-typescript": "^4.0.0",
"@types/cheerio": "^0.22.17",
"@types/jest": "^25.1.4",
"@types/lodash.debounce": "^4.0.6",
"@types/markdown-it": "^0.0.9",
"@types/vscode": "~1.36.0",
Expand All @@ -228,28 +227,33 @@
"markdown-it": "^10.0.0",
"nanoid": "^2.1.11",
"npm-run-all": "^4.1.5",
"prettier": "^1.19.1",
"prettier": "^2.0.1",
"rehype-parse": "^6.0.2",
"remark": "^11.0.2",
"remark-parse": "^7.0.2",
"rimraf": "^3.0.2",
"rollup": "^1.31.1",
"rollup-plugin-terser": "^5.2.0",
"stylelint": "^13.2.0",
"rollup": "^2.1.0",
"rollup-plugin-terser": "^5.3.0",
"stylelint": "^13.2.1",
"stylelint-config-prettier": "^8.0.1",
"stylelint-config-standard": "^20.0.0",
"ts-jest": "^25.2.1",
"tslint": "^6.0.0",
"tslint": "^6.1.0",
"tslint-config-airbnb": "^5.11.2",
"tslint-config-prettier": "^1.18.0",
"typescript": "^3.8.2",
"typescript": "^3.8.3",
"unified": "^8.4.2",
"unist-util-visit": "^2.0.2",
"yaml": "^1.7.2"
"yaml": "^1.8.3"
},
"dependencies": {
"@marp-team/marp-cli": "^0.17.1",
"@marp-team/marp-core": "^1.0.1",
"@marp-team/marp-cli": "^0.17.3",
"@marp-team/marp-core": "^1.1.0",
"axios": "^0.19.2"
},
"resolutions": {
"**/chrome-launcher/mkdirp": "^0.5.3",
"**/extract-zip/mkdirp": "^0.5.3",
"**/gonzales-pe/minimist": "^1.2.5"
}
}
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const plugins = [
json({ preferConst: true }),
nodeResolve({ mainFields: ['module', 'jsnext:main', 'main'] }),
commonjs(),
typescript({ module: 'esnext' }),
typescript(),
!process.env.ROLLUP_WATCH && terser(),
]

Expand Down
2 changes: 1 addition & 1 deletion src/__mocks__/lodash.debounce.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = f => (...args) => f(...args)
module.exports = (f) => (...args) => f(...args)
4 changes: 2 additions & 2 deletions src/__mocks__/vscode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const env = {
}

export const languages = {
createDiagnosticCollection: jest.fn(name => ({
createDiagnosticCollection: jest.fn((name) => ({
name,
delete: jest.fn(),
set: jest.fn(),
Expand Down Expand Up @@ -118,7 +118,7 @@ export const workspace = {
getConfiguration: jest.fn((section?: string) => ({
get: jest.fn(
(subSection?: string) =>
currentConf[[section, subSection].filter(s => s).join('.')]
currentConf[[section, subSection].filter((s) => s).join('.')]
),
})),
getWorkspaceFolder: jest.fn(),
Expand Down
2 changes: 1 addition & 1 deletion src/commands/toggle-marp-preview.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('#toggle', () => {
document: { getText: () => text },
}

textEditorMock.edit = jest.fn(callback => {
textEditorMock.edit = jest.fn((callback) => {
const builder = editBuilder()
textEditorMock._editBuilders.push(builder)

Expand Down
6 changes: 3 additions & 3 deletions src/commands/toggle-marp-preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ export const toggle = async (editor: TextEditor) => {
}

if (targetRange && toggleValue) {
await editor.edit(e => e.replace(targetRange!, toggleValue!))
await editor.edit((e) => e.replace(targetRange!, toggleValue!))
} else {
await editor.edit(e =>
await editor.edit((e) =>
e.insert(new Position(line - 1, 0), 'marp: true\n')
)
}
} else {
await editor.edit(e =>
await editor.edit((e) =>
e.insert(new Position(0, 0), '---\nmarp: true\n---\n\n')
)
}
Expand Down
12 changes: 6 additions & 6 deletions src/diagnostics/deprecated-dollar-prefix.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ describe('[Diagnostics rule] Deprecated dollar prefix', () => {

const diagnostics = register(document)
expect(diagnostics).toHaveLength(3)
expect(diagnostics.every(d => d instanceof Diagnostic)).toBe(true)
expect(diagnostics.every(d => d.source === 'marp-vscode')).toBe(true)
expect(diagnostics.every(d => d.code === rule.code)).toBe(true)
expect(diagnostics.every((d) => d instanceof Diagnostic)).toBe(true)
expect(diagnostics.every((d) => d.source === 'marp-vscode')).toBe(true)
expect(diagnostics.every((d) => d.code === rule.code)).toBe(true)

const [$size, $headingDivider, $style] = diagnostics
expect($size.range).toStrictEqual(
Expand Down Expand Up @@ -116,9 +116,9 @@ describe('[Diagnostics rule] Deprecated dollar prefix', () => {

const diagnostics = register(document)
expect(diagnostics).toHaveLength(4)
expect(diagnostics.every(d => d instanceof Diagnostic)).toBe(true)
expect(diagnostics.every(d => d.source === 'marp-vscode')).toBe(true)
expect(diagnostics.every(d => d.code === rule.code)).toBe(true)
expect(diagnostics.every((d) => d instanceof Diagnostic)).toBe(true)
expect(diagnostics.every((d) => d.source === 'marp-vscode')).toBe(true)
expect(diagnostics.every((d) => d.code === rule.code)).toBe(true)

const [$theme, $size, $style, $headingDivider] = diagnostics
expect($theme.range).toStrictEqual(
Expand Down
4 changes: 2 additions & 2 deletions src/diagnostics/deprecated-dollar-prefix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ export class RemoveDollarPrefix implements CodeActionProvider {
context
) =>
context.diagnostics
.filter(d => d.source === 'marp-vscode' && d.code === code)
.map(d => this.createCodeAction(d, doc))
.filter((d) => d.source === 'marp-vscode' && d.code === code)
.map((d) => this.createCodeAction(d, doc))

private createCodeAction(diag: Diagnostic, doc: TextDocument): CodeAction {
const act = new CodeAction(
Expand Down
6 changes: 3 additions & 3 deletions src/diagnostics/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ export function subscribe(subscriptions: Disposable[]) {
if (window.activeTextEditor) refresh(window.activeTextEditor.document)

subscriptions.push(
window.onDidChangeActiveTextEditor(e => e && refresh(e.document)),
workspace.onDidChangeTextDocument(e => refresh(e.document)),
workspace.onDidCloseTextDocument(d => collection.delete(d.uri))
window.onDidChangeActiveTextEditor((e) => e && refresh(e.document)),
workspace.onDidChangeTextDocument((e) => refresh(e.document)),
workspace.onDidCloseTextDocument((d) => collection.delete(d.uri))
)
}

Expand Down
6 changes: 2 additions & 4 deletions src/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,7 @@ describe('#extendMarkdownIt', () => {

it('adds code-line class and data-line attribute to DOM', () => {
const $ = cheerio.load(
extension()
.extendMarkdownIt(new markdownIt())
.render(markdown)
extension().extendMarkdownIt(new markdownIt()).render(markdown)
)

// SVG slides
Expand Down Expand Up @@ -244,7 +242,7 @@ describe('#extendMarkdownIt', () => {
setConfiguration({ 'markdown.marp.themes': ['../test.css'] })

const markdown = md()
markdown.normalizeLink = url => path.resolve(baseDir, url)
markdown.normalizeLink = (url) => path.resolve(baseDir, url)

await Promise.all(themes.loadStyles(Uri.parse(baseDir)))
expect(markdown.render(marpMd('<!--theme: example-->'))).not.toContain(
Expand Down
14 changes: 7 additions & 7 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ export function extendMarkdownIt(md: any) {

// Load custom themes
Promise.all(
themes.loadStyles(baseFolder).map(p =>
themes.loadStyles(baseFolder).map((p) =>
p.then(
theme => theme.registered,
e => console.error(e)
(theme) => theme.registered,
(e) => console.error(e)
)
)
).then(registered => {
if (registered.some(f => f === true)) {
).then((registered) => {
if (registered.some((f) => f === true)) {
commands.executeCommand('markdown.preview.refresh')
}
})
Expand Down Expand Up @@ -119,8 +119,8 @@ export const activate = ({ subscriptions }: ExtensionContext) => {
toggleMarpPreview
),
themes,
workspace.onDidChangeConfiguration(e => {
if (shouldRefreshConfs.some(c => e.affectsConfiguration(c))) {
workspace.onDidChangeConfiguration((e) => {
if (shouldRefreshConfs.some((c) => e.affectsConfiguration(c))) {
clearMarpCoreOptionCache()
commands.executeCommand('markdown.preview.refresh')
}
Expand Down
2 changes: 1 addition & 1 deletion src/option.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ describe('Option', () => {
expect(themeSet).toHaveLength(1)
expect((await readFile(themeSet[0])).toString()).toBe(css)
} finally {
await Promise.all(vscode.themeFiles.map(w => w.cleanup()))
await Promise.all(vscode.themeFiles.map((w) => w.cleanup()))
}
})
})
Expand Down
8 changes: 4 additions & 4 deletions src/option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ export const marpCoreOptionForCLI = async ({ uri }: TextDocument) => {
await Promise.all(
themes
.loadStyles(baseFolder ? Uri.parse(`file:${baseFolder}`) : undefined)
.map(promise =>
.map((promise) =>
promise.then(
async theme => {
async (theme) => {
if (theme.type === ThemeType.File) {
return { path: theme.path, cleanup: () => Promise.resolve() }
}
Expand All @@ -82,13 +82,13 @@ export const marpCoreOptionForCLI = async ({ uri }: TextDocument) => {
return { path: tmp, cleanup: () => promisify(unlink)(tmp) }
}
},
e => console.error(e)
(e) => console.error(e)
)
)
)
).filter((w): w is WorkFile => !!w)

baseOpts.themeSet = themeFiles.map(w => w.path)
baseOpts.themeSet = themeFiles.map((w) => w.path)
baseOpts.vscode.themeFiles = themeFiles

return baseOpts
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/custom-theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ export class CustomThemeError extends Error {}

export default function marpVSCodeCustomTheme(instance) {
const { marpit, parse } = instance
const registeredThemes = [...marpit.themeSet.themes()].map(t => t.name)
const registeredThemes = [...marpit.themeSet.themes()].map((t) => t.name)
const { addTheme } = marpit.themeSet

// `size` global directive support in Marp Core may override an instance of
// default themes. Even if default themes were overridden, we should not throw
// error while parsing Markdown by markdown-it.
let whileParsing = false

marpit.themeSet.addTheme = theme => {
marpit.themeSet.addTheme = (theme) => {
if (!whileParsing && registeredThemes.includes(theme.name)) {
throw new CustomThemeError(
`Custom theme cannot override "${theme.name}" built-in theme.`
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/line-number.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function marpVSCodeLineNumber(md) {
md.renderer.rules.marpit_inline_svg_open = (tokens, idx, opts, env, self) => {
const slide = tokens
.slice(idx + 1)
.find(t => t.type === 'marpit_slide_open')
.find((t) => t.type === 'marpit_slide_open')

if (slide.map?.length) {
tokens[idx].attrJoin('class', 'code-line')
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/outline.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default function marpVSCodeOutline(instance) {
instance.core.ruler.push('marp_vscode_outline', state => {
instance.core.ruler.push('marp_vscode_outline', (state) => {
if (state.inlineMode) return

const tokens: any[] = []
Expand Down
4 changes: 2 additions & 2 deletions src/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export default function preview() {
const links = document.querySelectorAll(
'link[rel="stylesheet"]:not([href*="marp-vscode"])'
)
styles.forEach(elm => elm.remove())
links.forEach(elm => elm.remove())
styles.forEach((elm) => elm.remove())
links.forEach((elm) => elm.remove())

// Run Marp observer
browser()
Expand Down
10 changes: 6 additions & 4 deletions src/themes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class Themes {
observedThemes = new Map<string, Theme>()

dispose() {
this.observedThemes.forEach(theme => {
this.observedThemes.forEach((theme) => {
if (theme.onDidChange) theme.onDidChange.dispose()
if (theme.onDidDelete) theme.onDidDelete.dispose()
})
Expand All @@ -39,12 +39,14 @@ export class Themes {

getRegisteredStyles(rootDirectory: Uri | undefined): Theme[] {
return this.getPathsFromConf(rootDirectory)
.map(p => this.observedThemes.get(p))
.filter(t => t) as Theme[]
.map((p) => this.observedThemes.get(p))
.filter((t) => t) as Theme[]
}

loadStyles(rootDirectory: Uri | undefined): Promise<Theme>[] {
return this.getPathsFromConf(rootDirectory).map(p => this.registerTheme(p))
return this.getPathsFromConf(rootDirectory).map((p) =>
this.registerTheme(p)
)
}

private getPathsFromConf(rootDirectory: Uri | undefined): string[] {
Expand Down
3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
"compilerOptions": {
"esModuleInterop": true,
"lib": ["es6", "dom"],
"module": "commonjs",
"module": "esnext",
"moduleResolution": "node",
"noImplicitAny": false,
"outDir": "lib",
"resolveJsonModule": true,
"sourceMap": true,
"strict": true,
Expand Down
Loading