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 #301

Merged
merged 5 commits into from
May 13, 2021
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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ commands:
- checkout
- install:
postinstall:
- run: yarn audit
- run: yarn -s check:audit

test:
steps:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [Unreleased]

### Changed

- Upgrade dependent packages to the latest version ([#301](https://github.com/marp-team/marpit/pull/301))

## v2.0.1 - 2021-04-27

### Fixed
Expand Down
34 changes: 17 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
},
"scripts": {
"build": "yarn -s clean && babel src --out-dir lib",
"check:audit": "yarn audit",
"check:audit": "echo \"[WARNING] Temporally limited yarn audit only to dependencies.\" && yarn audit --groups dependencies",
"check:format": "yarn -s run format -c",
"clean": "rimraf lib",
"docs": "node ./docsify/serve.js",
Expand All @@ -59,43 +59,43 @@
"watch": "babel src --out-dir lib -w --verbose"
},
"devDependencies": {
"@babel/cli": "^7.13.10",
"@babel/core": "^7.13.10",
"@babel/preset-env": "^7.13.12",
"@babel/cli": "^7.13.16",
"@babel/core": "^7.14.2",
"@babel/preset-env": "^7.14.2",
"autoprefixer": "^10.2.5",
"babel-eslint": "^10.1.0",
"cheerio": "^1.0.0-rc.5",
"cheerio": "^1.0.0-rc.9",
"chokidar": "^3.5.1",
"codecov": "^3.8.1",
"cssnano": "^5.0.0-rc.2",
"codecov": "^3.8.2",
"cssnano": "^5.0.2",
"dedent": "^0.7.0",
"docsify-themeable": "^0.8.4",
"eslint": "^7.22.0",
"eslint-config-prettier": "^8.1.0",
"eslint": "^7.26.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.22.1",
"jest": "^26.6.3",
"jest-junit": "^12.0.0",
"jsdoc": "^3.6.6",
"minami": "^1.2.3",
"npm-run-all": "^4.1.5",
"prettier": "^2.2.1",
"prettier": "^2.3.0",
"rimraf": "^3.0.2",
"sass": "1.32.8",
"sass": "1.32.13",
"serve-handler": "^6.1.3",
"stylelint": "^13.12.0",
"stylelint": "^13.13.1",
"stylelint-config-prettier": "^8.0.2",
"stylelint-config-standard": "^21.0.0",
"stylelint-config-standard": "^22.0.0",
"stylelint-scss": "^3.19.0",
"ws": "^7.4.4"
"ws": "^7.4.5"
},
"dependencies": {
"color-string": "^1.5.5",
"cssesc": "^3.0.0",
"js-yaml": "^4.0.0",
"js-yaml": "^4.1.0",
"lodash.kebabcase": "^4.1.1",
"markdown-it": "^12.0.4",
"markdown-it": "^12.0.6",
"markdown-it-front-matter": "^0.2.3",
"postcss": "^8.2.8"
"postcss": "^8.2.15"
},
"resolutions": {
"normalize-package-data": "^3.0.2",
Expand Down
71 changes: 36 additions & 35 deletions src/postcss/import/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,50 +28,51 @@ import postcssPlugin from '../../helpers/postcss_plugin'
*/
const plugin = postcssPlugin(
'marpit-postcss-import-parse',
() => (css, { result }) => {
const imports = { import: [], importTheme: [] }
let allowImport = true
() =>
(css, { result }) => {
const imports = { import: [], importTheme: [] }
let allowImport = true

css.walk((node) => {
if (node.type === 'atrule') {
const push = (target) => {
const [quote] = node.params
if (quote !== '"' && quote !== "'") return
css.walk((node) => {
if (node.type === 'atrule') {
const push = (target) => {
const [quote] = node.params
if (quote !== '"' && quote !== "'") return

const splitedValue = node.params.slice(1).split(quote)
let value = ''
const splitedValue = node.params.slice(1).split(quote)
let value = ''

splitedValue.every((v) => {
if (v.endsWith('\\')) {
value = `${value}${v.slice(0, -1)}${quote}`
return true
}
value = `${value}${v}`
return false
})
splitedValue.every((v) => {
if (v.endsWith('\\')) {
value = `${value}${v.slice(0, -1)}${quote}`
return true
}
value = `${value}${v}`
return false
})

node.marpitImportParse = value
target.push({ node, value })
}
node.marpitImportParse = value
target.push({ node, value })
}

if (allowImport) {
if (node.name === 'import') {
push(imports.import)
} else if (node.name !== 'charset') {
allowImport = false
if (allowImport) {
if (node.name === 'import') {
push(imports.import)
} else if (node.name !== 'charset') {
allowImport = false
}
}
}

if (node.name === 'import-theme' && node.parent.type === 'root') {
push(imports.importTheme)
if (node.name === 'import-theme' && node.parent.type === 'root') {
push(imports.importTheme)
}
} else if (node.type !== 'comment') {
allowImport = false
}
} else if (node.type !== 'comment') {
allowImport = false
}
})
})

result.marpitImport = [...imports.importTheme, ...imports.import]
}
result.marpitImport = [...imports.importTheme, ...imports.import]
}
)

export default plugin
57 changes: 29 additions & 28 deletions src/postcss/import/replace.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,38 @@ const plugin = (themeSet, importedThemes = []) =>
postcssImportParse(),
postcssPlugin(
'marpit-postcss-import-replace-processor',
() => (css, { postcss }) => {
const prepends = []

css.walk((node) => {
const name = node.marpitImportParse

if (name) {
const theme = themeSet.get(name)

if (theme) {
if (importedThemes.includes(name))
throw new Error(
`Circular "${name}" theme import is detected.`
)

const processed = postcss([
plugin(themeSet, [...importedThemes, name]),
]).process(theme.css)

if (node.name === 'import') {
node.replaceWith(processed.root)
} else {
node.remove()
prepends.unshift(processed.root)
() =>
(css, { postcss }) => {
const prepends = []

css.walk((node) => {
const name = node.marpitImportParse

if (name) {
const theme = themeSet.get(name)

if (theme) {
if (importedThemes.includes(name))
throw new Error(
`Circular "${name}" theme import is detected.`
)

const processed = postcss([
plugin(themeSet, [...importedThemes, name]),
]).process(theme.css)

if (node.name === 'import') {
node.replaceWith(processed.root)
} else {
node.remove()
prepends.unshift(processed.root)
}
}
}
}
})
})

for (const root of prepends) css.first.before(root)
}
for (const root of prepends) css.first.before(root)
}
)(),
],
}))
Expand Down
41 changes: 21 additions & 20 deletions src/postcss/meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,29 @@ import postcssPlugin from '../helpers/postcss_plugin'
*/
const plugin = postcssPlugin(
'marpit-postcss-meta',
(opts = {}) => (css, { result }) => {
const metaType = opts.metaType || {}
(opts = {}) =>
(css, { result }) => {
const metaType = opts.metaType || {}

result.marpitMeta = result.marpitMeta || {}
result.marpitMeta = result.marpitMeta || {}

css.walkComments((comment) => {
comment.text
.slice(0)
.replace(/^[*!\s]*@([\w-]+)\s+(.+)$/gim, (_, metaName, value) => {
if (metaType[metaName] === Array) {
// Array meta
result.marpitMeta[metaName] = [
...(result.marpitMeta[metaName] || []),
value,
]
} else {
// String meta (default)
result.marpitMeta[metaName] = value
}
})
})
}
css.walkComments((comment) => {
comment.text
.slice(0)
.replace(/^[*!\s]*@([\w-]+)\s+(.+)$/gim, (_, metaName, value) => {
if (metaType[metaName] === Array) {
// Array meta
result.marpitMeta[metaName] = [
...(result.marpitMeta[metaName] || []),
value,
]
} else {
// String meta (default)
result.marpitMeta[metaName] = value
}
})
})
}
)

export default plugin
28 changes: 15 additions & 13 deletions src/postcss/root/rem.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,22 @@ const skipParsingMatcher = /("[^"]*"|'[^']*'|(?:attr|url|var)\([^)]*\))/g
*
* @alias module:postcss/root/rem
*/
const plugin = postcssPlugin('marpit-postcss-rem', () => (css) =>
css.walkDecls((decl) => {
decl.value = decl.value
.split(skipParsingMatcher)
.map((v, i) => {
if (i % 2) return v
const plugin = postcssPlugin(
'marpit-postcss-rem',
() => (css) =>
css.walkDecls((decl) => {
decl.value = decl.value
.split(skipParsingMatcher)
.map((v, i) => {
if (i % 2) return v

return v.replace(
/(\d*\.?\d+)rem\b/g,
(_, num) => `calc(var(${rootFontSizeCustomProp}, 1rem) * ${num})`
)
})
.join('')
})
return v.replace(
/(\d*\.?\d+)rem\b/g,
(_, num) => `calc(var(${rootFontSizeCustomProp}, 1rem) * ${num})`
)
})
.join('')
})
)

export default plugin
19 changes: 10 additions & 9 deletions src/postcss/root/replace.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@ import postcssPlugin from '../../helpers/postcss_plugin'
*/
const plugin = postcssPlugin(
'marpit-postcss-root-replace',
({ pseudoClass } = {}) => (css) =>
css.walkRules((rule) => {
// Replace `:root` pseudo-class selectors into `section`
rule.selectors = rule.selectors.map((selector) =>
selector.replace(
/(^|[\s>+~(])(?:section)?:root\b/g,
(_, s) => `${s}section${pseudoClass || ''}`
({ pseudoClass } = {}) =>
(css) =>
css.walkRules((rule) => {
// Replace `:root` pseudo-class selectors into `section`
rule.selectors = rule.selectors.map((selector) =>
selector.replace(
/(^|[\s>+~(])(?:section)?:root\b/g,
(_, s) => `${s}section${pseudoClass || ''}`
)
)
)
})
})
)

export default plugin
10 changes: 6 additions & 4 deletions src/theme_set.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,9 @@ class ThemeSet {
const packer = postcss(
[
before &&
postcssPlugin('marpit-pack-before', () => (css) =>
css.first.before(before)
postcssPlugin(
'marpit-pack-before',
() => (css) => css.first.before(before)
),
after &&
postcssPlugin('marpit-pack-after', () => (css) => {
Expand All @@ -278,8 +279,9 @@ class ThemeSet {
height: this.getThemeProp(theme, 'height'),
}),
theme !== scaffold &&
postcssPlugin('marpit-pack-scaffold', () => (css) =>
css.first.before(scaffold.css)
postcssPlugin(
'marpit-pack-scaffold',
() => (css) => css.first.before(scaffold.css)
),
opts.inlineSVG && postcssAdvancedBackground,
postcssPagination,
Expand Down
Loading