Skip to content

Commit

Permalink
Merge pull request #548 from marp-team/upgrade-dependencies
Browse files Browse the repository at this point in the history
Upgrade dependent packages to the latest version
  • Loading branch information
yhatt authored Sep 23, 2023
2 parents a4d45af + 344b13c commit 944cb38
Show file tree
Hide file tree
Showing 16 changed files with 1,438 additions and 1,553 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

### Changed

- Upgrade Marpit to [v2.5.3](https://github.com/marp-team/marpit/releases/tag/v2.5.3) ([#548](https://github.com/marp-team/marp-cli/pull/548))
- Upgrade Marp Core to [v3.8.1](https://github.com/marp-team/marp-core/releases/v3.8.1) ([#548](https://github.com/marp-team/marp-cli/pull/548))
- Upgrade development Node.js LTS to v18.18.0 ([#547](https://github.com/marp-team/marp-cli/pull/547))
- Upgrade dependent packages to the latest versions ([#548](https://github.com/marp-team/marp-cli/pull/548))

## v3.2.1 - 2023-08-24

Expand Down
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const esModules = [
'import-meta-resolve',
'is-inside-container',
'is-docker',
'is-wsl',
'lighthouse-logger',
'locate-path',
'nanoid',
Expand Down
66 changes: 33 additions & 33 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,28 +70,28 @@
"watch": "rollup -w -c"
},
"devDependencies": {
"@babel/preset-env": "^7.22.9",
"@babel/preset-env": "^7.22.20",
"@rollup/plugin-alias": "^5.0.0",
"@rollup/plugin-commonjs": "^25.0.3",
"@rollup/plugin-commonjs": "^25.0.4",
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.1.0",
"@rollup/plugin-node-resolve": "^15.2.1",
"@rollup/plugin-replace": "^5.0.2",
"@rollup/plugin-terser": "^0.4.3",
"@rollup/plugin-typescript": "^11.1.2",
"@rollup/plugin-typescript": "^11.1.3",
"@rollup/plugin-url": "^8.0.1",
"@tsconfig/node14": "^14.1.0",
"@types/cheerio": "^0.22.31",
"@types/cheerio": "^0.22.32",
"@types/express": "^4.17.17",
"@types/jest": "^29.5.3",
"@types/markdown-it": "^12.2.3",
"@types/jest": "^29.5.5",
"@types/markdown-it": "^13.0.1",
"@types/node": "~16.18.38",
"@types/pug": "^2.0.6",
"@types/supertest": "^2.0.12",
"@types/ws": "^8.5.5",
"@types/yargs": "^17.0.24",
"@typescript-eslint/eslint-plugin": "^6.2.1",
"@typescript-eslint/parser": "^6.2.1",
"autoprefixer": "^10.4.14",
"@typescript-eslint/eslint-plugin": "^6.7.2",
"@typescript-eslint/parser": "^6.7.2",
"autoprefixer": "^10.4.16",
"babel-plugin-transform-rename-import": "^2.3.0",
"bespoke": "bespokejs/bespoke",
"builtin-modules": "^3.3.0",
Expand All @@ -100,12 +100,12 @@
"chrome-launcher": "^1.0.0",
"css.escape": "^1.5.1",
"cssnano": "^6.0.1",
"eslint": "^8.46.0",
"eslint-config-prettier": "^8.10.0",
"eslint": "^8.50.0",
"eslint-config-prettier": "^9.0.0",
"eslint-import-resolver-exports": "^1.0.0-beta.5",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-import": "^2.28.0",
"eslint-plugin-jest": "^27.2.3",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-jest": "^27.4.0",
"express": "^4.18.2",
"fast-plist": "^0.1.3",
"get-stdin": "^9.0.0",
Expand All @@ -114,8 +114,9 @@
"import-from": "^4.0.0",
"import-meta-resolve": "^3.0.0",
"is-inside-container": "^1.0.0",
"jest": "^29.6.2",
"jest-environment-jsdom": "^29.6.2",
"is-wsl": "^3.0.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-junit": "^16.0.0",
"nanoid": "^4.0.2",
"npm-run-all2": "^6.0.6",
Expand All @@ -124,43 +125,42 @@
"pkg": "^5.8.1",
"pkg-up": "^4.0.0",
"portfinder": "1.0.32",
"postcss": "^8.4.27",
"postcss": "^8.4.30",
"postcss-url": "^10.1.3",
"pptxgenjs": "^3.12.0",
"prettier": "^3.0.1",
"prettier": "^3.0.3",
"pug": "^3.0.2",
"rimraf": "^5.0.1",
"rollup": "^3.27.2",
"rollup-plugin-license": "^3.0.1",
"rollup": "^3.29.2",
"rollup-plugin-license": "^3.1.0",
"rollup-plugin-postcss": "^4.0.2",
"rollup-plugin-pug": "^1.1.1",
"sass": "^1.64.2",
"sass": "^1.68.0",
"strip-ansi": "^7.1.0",
"stylelint": "^15.10.2",
"stylelint-config-standard-scss": "^10.0.0",
"stylelint": "^15.10.3",
"stylelint-config-standard-scss": "^11.0.0",
"supertest": "^6.3.3",
"tar-stream": "^3.1.6",
"ts-jest": "^29.1.1",
"ts-key-enum": "^3.0.12",
"tslib": "^2.6.1",
"tslib": "^2.6.2",
"typed-emitter": "^2.1.0",
"typescript": "^5.1.6",
"typescript": "^5.2.2",
"vhtml": "^2.2.0",
"wrap-ansi": "^8.1.0",
"yauzl": "^2.10.0",
"zip-stream": "^4.1.0"
"zip-stream": "^5.0.1"
},
"dependencies": {
"@marp-team/marp-core": "^3.8.0",
"@marp-team/marpit": "^2.5.0",
"@marp-team/marp-core": "^3.8.1",
"@marp-team/marpit": "^2.5.3",
"chokidar": "^3.5.3",
"cosmiconfig": "^8.2.0",
"is-wsl": "^2.2.0",
"puppeteer-core": "21.0.1",
"cosmiconfig": "^8.3.6",
"puppeteer-core": "21.3.4",
"remove": "^0.1.5",
"serve-index": "^1.9.1",
"tmp": "^0.2.1",
"ws": "^8.13.0",
"ws": "^8.14.2",
"yargs": "^17.7.2"
},
"resolutions": {
Expand Down
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ export class MarpCLIConfig {

try {
const ret = await (confPath === undefined
? explorer.search()
? explorer.search(process.cwd())
: explorer.load(confPath))

if (ret) {
Expand Down
8 changes: 4 additions & 4 deletions src/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ export class Converter {
if (this.options.baseUrl) return this.options.baseUrl

if (isFile(f) && type !== ConvertType.html) {
return isChromeInWSLHost(
return (await isChromeInWSLHost(
(await generatePuppeteerLaunchArgs()).executablePath
)
))
? `file:${await resolveWSLPathToHost(f.absolutePath)}`
: f.absoluteFileScheme
}
Expand Down Expand Up @@ -557,7 +557,7 @@ export class Converter {

const uri = await (async () => {
if (tmpFile) {
if (isChromeInWSLHost(browser.process()?.spawnfile)) {
if (await isChromeInWSLHost(browser.process()?.spawnfile)) {
// Windows Chrome should read file from WSL environment
return `file:${await resolveWSLPathToHost(tmpFile.path)}`
}
Expand Down Expand Up @@ -641,7 +641,7 @@ export class Converter {
...baseArgs,
timeout,
userDataDir: await generatePuppeteerDataDirPath('marp-cli-conversion', {
wslHost: isChromeInWSLHost(baseArgs.executablePath),
wslHost: await isChromeInWSLHost(baseArgs.executablePath),
}),
})
Converter.browser.once('disconnected', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export class Preview extends (EventEmitter as new () => TypedEmitter<Preview.Eve
headless: process.env.NODE_ENV === 'test' ? enableHeadless() : false,
ignoreDefaultArgs: ['--enable-automation'],
userDataDir: await generatePuppeteerDataDirPath('marp-cli-preview', {
wslHost: isChromeInWSLHost(baseArgs.executablePath),
wslHost: await isChromeInWSLHost(baseArgs.executablePath),
}),
})

Expand Down
2 changes: 1 addition & 1 deletion src/utils/chrome-finder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const findChromeInstallation = async () => {
// 'wsl' platform will resolve Chrome from Windows. In WSL 2, Puppeteer cannot
// communicate with Chrome spawned in the host OS so should follow the
// original platform ('linux') if CLI was executed in WSL 2.
const platform = isWSL() === 1 ? 'wsl' : process.platform
const platform = (await isWSL()) === 1 ? 'wsl' : process.platform

const installations = await (async () => {
switch (platform) {
Expand Down
8 changes: 4 additions & 4 deletions src/utils/edge-finder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ export const findAccessiblePath = (paths: string[]): string | undefined =>
return false
})

const linux = (): string | undefined => {
const linux = async (): Promise<string | undefined> => {
// WSL 1 should find Edge executable from host OS
if (isWSL() === 1) {
if ((await isWSL()) === 1) {
const localAppData = resolveWindowsEnvSync('LOCALAPPDATA')

return win32({
Expand Down Expand Up @@ -70,8 +70,8 @@ const win32 = ({
)
}

export const findEdgeInstallation = (): string | undefined => {
if (process.platform === 'linux') return linux()
export const findEdgeInstallation = async (): Promise<string | undefined> => {
if (process.platform === 'linux') return await linux()
if (process.platform === 'darwin') return darwin()
if (process.platform === 'win32') return win32()

Expand Down
6 changes: 3 additions & 3 deletions src/utils/puppeteer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const generatePuppeteerDataDirPath = async (
{ wslHost }: { wslHost?: boolean } = {}
): Promise<string> => {
const dataDir = await (async () => {
if (isWSL() && wslHost) {
if ((await isWSL()) && wslHost) {
// In WSL environment, Marp CLI may use Chrome on Windows. If Chrome has
// located in host OS (Windows), we have to specify Windows path.
if (wslTmp === undefined) wslTmp = await resolveWindowsEnv('TMP')
Expand All @@ -76,7 +76,7 @@ export const generatePuppeteerLaunchArgs = async () => {
const args = new Set<string>(['--export-tagged-pdf', '--test-type'])

// Docker environment and WSL environment need to disable sandbox. :(
if (isInsideContainer() || isWSL()) args.add('--no-sandbox')
if (isInsideContainer() || (await isWSL())) args.add('--no-sandbox')

// Workaround for Chrome 73 in docker and unit testing with CircleCI
// https://github.com/GoogleChrome/puppeteer/issues/3774
Expand Down Expand Up @@ -104,7 +104,7 @@ export const generatePuppeteerLaunchArgs = async () => {

if (!executablePath) {
// Find Edge as fallback (Edge has pre-installed to almost Windows)
executablePath = findEdgeInstallation()
executablePath = await findEdgeInstallation()

if (!executablePath) {
if (findChromeError) warn(findChromeError.message)
Expand Down
8 changes: 4 additions & 4 deletions src/utils/wsl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ export const resolveWindowsEnvSync = (key: string): string | undefined => {
return ret.startsWith(`${key}=`) ? ret.slice(key.length + 1) : undefined
}

export const isWSL = (): number => {
export const isWSL = async (): Promise<number> => {
if (isWsl === undefined) {
if (require('is-wsl')) {
if ((await import('is-wsl')).default) {
// Detect whether WSL version is 2
// https://github.com/microsoft/WSL/issues/4555#issuecomment-700213318
const isWSL2 = (() => {
Expand All @@ -57,5 +57,5 @@ export const isWSL = (): number => {
return isWsl
}

export const isChromeInWSLHost = (chromePath: string | undefined) =>
!!(isWSL() && chromePath?.match(/^\/mnt\/[a-z]\//))
export const isChromeInWSLHost = async (chromePath: string | undefined) =>
!!((await isWSL()) && chromePath?.match(/^\/mnt\/[a-z]\//))
2 changes: 1 addition & 1 deletion test/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { load } from 'cheerio'
import { imageSize } from 'image-size'
import { PDFDocument, PDFDict, PDFName, PDFHexString, PDFNumber } from 'pdf-lib'
import { TimeoutError } from 'puppeteer-core'
import { CDPPage as Page } from 'puppeteer-core/lib/cjs/puppeteer/common/Page'
import { CdpPage as Page } from 'puppeteer-core/lib/cjs/puppeteer/cdp/Page'
import yauzl from 'yauzl'
import { Converter, ConvertType, ConverterOption } from '../src/converter'
import { CLIError } from '../src/error'
Expand Down
3 changes: 2 additions & 1 deletion test/marp-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import fs from 'fs'
import path from 'path'
import { version as coreVersion } from '@marp-team/marp-core/package.json'
import { version as marpitVersion } from '@marp-team/marpit/package.json'
import { Explorer } from 'cosmiconfig/dist/Explorer'
import * as cosmiconfigExplorer from 'cosmiconfig/dist/Explorer'
import getStdin from 'get-stdin'
import stripAnsi from 'strip-ansi'
import { version as cliVersion } from '../package.json'
Expand All @@ -24,6 +24,7 @@ import * as container from '../src/utils/container'
import * as version from '../src/version'
import { Watcher } from '../src/watcher'

const { Explorer } = cosmiconfigExplorer as any
const observationHelpers: ObservationHelper[] = []
const previewEmitter = new EventEmitter() as Preview

Expand Down
24 changes: 13 additions & 11 deletions test/utils/edge-finder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('#findEdgeInstallation', () => {
Object.defineProperty(process, 'platform', { value: 'win32' })
})

it('finds out the first accessible Edge from 3 locations', () => {
it('finds out the first accessible Edge from 3 locations', async () => {
const currentEnv = process.env

const programFiles = path.join('C:', 'Mock', 'Program Files')
Expand All @@ -57,7 +57,7 @@ describe('#findEdgeInstallation', () => {
() => 'C:\\Program Files\\Microsoft\\Edge\\Application\\msedge.exe'
)

expect(edgeFinder.findEdgeInstallation()).toBe(
expect(await edgeFinder.findEdgeInstallation()).toBe(
'C:\\Program Files\\Microsoft\\Edge\\Application\\msedge.exe'
)
expect(findAccessiblePath.mock.calls[0][0]).toStrictEqual([
Expand Down Expand Up @@ -90,14 +90,14 @@ describe('#findEdgeInstallation', () => {
Object.defineProperty(process, 'platform', { value: 'darwin' })
})

it('finds out the first accessible Edge from specific paths', () => {
it('finds out the first accessible Edge from specific paths', async () => {
const findAccessiblePath = jest
.spyOn(edgeFinder, 'findAccessiblePath')
.mockImplementation(
() => '/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge'
)

expect(edgeFinder.findEdgeInstallation()).toBe(
expect(await edgeFinder.findEdgeInstallation()).toBe(
'/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge'
)
expect(findAccessiblePath.mock.calls[0][0]).toMatchInlineSnapshot(`
Expand All @@ -117,12 +117,12 @@ describe('#findEdgeInstallation', () => {
Object.defineProperty(process, 'platform', { value: 'linux' })
})

it('finds out the first accessible Edge from specific paths', () => {
it('finds out the first accessible Edge from specific paths', async () => {
const findAccessiblePath = jest
.spyOn(edgeFinder, 'findAccessiblePath')
.mockImplementation(() => '/opt/microsoft/msedge/msedge')

expect(edgeFinder.findEdgeInstallation()).toBe(
expect(await edgeFinder.findEdgeInstallation()).toBe(
'/opt/microsoft/msedge/msedge'
)
expect(findAccessiblePath.mock.calls[0][0]).toMatchInlineSnapshot(`
Expand All @@ -136,9 +136,11 @@ describe('#findEdgeInstallation', () => {
})

describe('on Windows WSL', () => {
beforeEach(() => jest.spyOn(wsl, 'isWSL').mockImplementation(() => 1))
beforeEach(() =>
jest.spyOn(wsl, 'isWSL').mockImplementation(async () => 1)
)

it('finds out the first accessible Edge from mounted Windows location', () => {
it('finds out the first accessible Edge from mounted Windows location', async () => {
const findAccessiblePath = jest
.spyOn(edgeFinder, 'findAccessiblePath')
.mockImplementation()
Expand All @@ -151,7 +153,7 @@ describe('#findEdgeInstallation', () => {
.spyOn(wsl, 'resolveWSLPathToGuestSync')
.mockImplementation(() => '/mnt/c/mock/Local')

edgeFinder.findEdgeInstallation()
await edgeFinder.findEdgeInstallation()
expect(resolveWindowsEnvSync).toHaveBeenCalledWith('LOCALAPPDATA')
expect(resolveWSLPathToGuestSync).toHaveBeenCalledWith(
'C:\\Mock\\Local'
Expand Down Expand Up @@ -180,8 +182,8 @@ describe('#findEdgeInstallation', () => {
Object.defineProperty(process, 'platform', { value: 'unknown' })
})

it('returns undefined', () => {
expect(edgeFinder.findEdgeInstallation()).toBeUndefined()
it('returns undefined', async () => {
expect(await edgeFinder.findEdgeInstallation()).toBeUndefined()
})
})
})
Loading

0 comments on commit 944cb38

Please sign in to comment.