Skip to content

Commit

Permalink
Merge pull request #212 from atls/feat/stabilize-deps
Browse files Browse the repository at this point in the history
feat: stabilize deps
  • Loading branch information
TorinAsakura authored Feb 17, 2022
2 parents 9d0e827 + 54e24e5 commit 0f464e4
Show file tree
Hide file tree
Showing 172 changed files with 3,233 additions and 2,499 deletions.
1,984 changes: 1,162 additions & 822 deletions .pnp.cjs

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion code/code-commit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"conventional-commits-parser": "^3.2.4"
},
"devDependencies": {
"@types/node": "^17.0.17"
"@types/node": "^17.0.10"
},
"publishConfig": {
"main": "dist/index.js",
Expand Down
302 changes: 151 additions & 151 deletions code/code-commit/src/lint/commitlint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,183 +21,183 @@ import defaultParserOpts from 'conventional-changelog-angular/parser-opts'
import { sync } from 'conventional-commits-parser'

export async function parse(
message: string,
parser: Parser = sync,
parserOpts?: ParserOptions
message: string,
parser: Parser = sync,
parserOpts?: ParserOptions
): Promise<Commit> {
const opts = {
...defaultParserOpts,
...(parserOpts || {}),
}
const opts = {
...defaultParserOpts,
...(parserOpts || {}),
}

const parsed = parser(message, opts) as Commit
const parsed = parser(message, opts) as Commit

parsed.raw = message
parsed.raw = message

return parsed
return parsed
}

export async function lint(
message: string,
rawRulesConfig?: QualifiedRules,
rawOpts?: LintOptions
message: string,
rawRulesConfig?: QualifiedRules,
rawOpts?: LintOptions
): Promise<LintOutcome> {
// eslint-disable-next-line no-unneeded-ternary
const opts = rawOpts ? rawOpts : { defaultIgnores: undefined, ignores: undefined }
const rulesConfig = rawRulesConfig || {}

// Found a wildcard match, skip
if (isIgnored(message, { defaults: opts.defaultIgnores, ignores: opts.ignores })) {
return {
valid: true,
errors: [],
warnings: [],
input: message,
}
}
// eslint-disable-next-line no-unneeded-ternary
const opts = rawOpts ? rawOpts : { defaultIgnores: undefined, ignores: undefined }
const rulesConfig = rawRulesConfig || {}

// Parse the commit message
const parsed =
message === ''
? { header: null, body: null, footer: null }
: await parse(message, undefined, opts.parserOpts)

if (parsed.header === null && parsed.body === null && parsed.footer === null) {
// Commit is empty, skip
return {
valid: true,
errors: [],
warnings: [],
input: message,
}
// Found a wildcard match, skip
if (isIgnored(message, { defaults: opts.defaultIgnores, ignores: opts.ignores })) {
return {
valid: true,
errors: [],
warnings: [],
input: message,
}
}

const allRules: Map<string, BaseRule<never, RuleType>> = new Map(Object.entries(defaultRules))
// Parse the commit message
const parsed =
message === ''
? { header: null, body: null, footer: null }
: await parse(message, undefined, opts.parserOpts)

if (opts.plugins) {
Object.values(opts.plugins).forEach((plugin) => {
if (plugin.rules) {
Object.keys(plugin.rules).forEach((ruleKey) => allRules.set(ruleKey, plugin.rules[ruleKey]))
}
})
if (parsed.header === null && parsed.body === null && parsed.footer === null) {
// Commit is empty, skip
return {
valid: true,
errors: [],
warnings: [],
input: message,
}

// Find invalid rules configs
const missing = Object.keys(rulesConfig).filter(
(name) => typeof allRules.get(name) !== 'function'
}

const allRules: Map<string, BaseRule<never, RuleType>> = new Map(Object.entries(defaultRules))

if (opts.plugins) {
Object.values(opts.plugins).forEach((plugin) => {
if (plugin.rules) {
Object.keys(plugin.rules).forEach((ruleKey) => allRules.set(ruleKey, plugin.rules[ruleKey]))
}
})
}

// Find invalid rules configs
const missing = Object.keys(rulesConfig).filter(
(name) => typeof allRules.get(name) !== 'function'
)

if (missing.length > 0) {
const names = [...allRules.keys()]
throw new RangeError(
`Found invalid rule names: ${missing.join(', ')}. Supported rule names are: ${names.join(
', '
)}`
)
}

const invalid = Object.entries(rulesConfig)
.map(([name, config]) => {
if (!Array.isArray(config)) {
return new Error(
`config for rule ${name} must be array, received ${util.inspect(
config
)} of type ${typeof config}`
)
}

const [level] = config

if (level === RuleConfigSeverity.Disabled && config.length === 1) {
return null
}

if (missing.length > 0) {
const names = [...allRules.keys()]
throw new RangeError(
`Found invalid rule names: ${missing.join(', ')}. Supported rule names are: ${names.join(
', '
)}`
const [, when] = config

if (typeof level !== 'number' || Number.isNaN(level)) {
return new Error(
`level for rule ${name} must be number, received ${util.inspect(
level
)} of type ${typeof level}`
)
}
}

const invalid = Object.entries(rulesConfig)
.map(([name, config]) => {
if (!Array.isArray(config)) {
return new Error(
`config for rule ${name} must be array, received ${util.inspect(
config
)} of type ${typeof config}`
)
}

const [level] = config

if (level === RuleConfigSeverity.Disabled && config.length === 1) {
return null
}

const [, when] = config

if (typeof level !== 'number' || Number.isNaN(level)) {
return new Error(
`level for rule ${name} must be number, received ${util.inspect(
level
)} of type ${typeof level}`
)
}

if (config.length !== 2 && config.length !== 3) {
return new Error(
`config for rule ${name} must be 2 or 3 items long, received ${util.inspect(
config
)} of length ${(config as any).length}`
)
}

if (level < 0 || level > 2) {
return new RangeError(
`level for rule ${name} must be between 0 and 2, received ${util.inspect(level)}`
)
}

if (typeof when !== 'string') {
return new Error(
`condition for rule ${name} must be string, received ${util.inspect(
when
)} of type ${typeof when}`
)
}

if (when !== 'never' && when !== 'always') {
return new Error(
`condition for rule ${name} must be "always" or "never", received ${util.inspect(when)}`
)
}

return null
})
.filter((item): item is Error => item instanceof Error)

if (invalid.length > 0) {
throw new Error(invalid.map((i) => i.message).join('\n'))
}
if (config.length !== 2 && config.length !== 3) {
return new Error(
`config for rule ${name} must be 2 or 3 items long, received ${util.inspect(
config
)} of length ${(config as any).length}`
)
}

// Validate against all rules
const pendingResults = Object.entries(rulesConfig)
// Level 0 rules are ignored
.filter(([, config]) => !!config && config.length && config[0] > 0)
.map(async (entry) => {
const [name, config] = entry
const [level, when, value] = config! //
if (level < 0 || level > 2) {
return new RangeError(
`level for rule ${name} must be between 0 and 2, received ${util.inspect(level)}`
)
}

const rule = allRules.get(name)
if (typeof when !== 'string') {
return new Error(
`condition for rule ${name} must be string, received ${util.inspect(
when
)} of type ${typeof when}`
)
}

if (!rule) {
throw new Error(`Could not find rule implementation for ${name}`)
}
if (when !== 'never' && when !== 'always') {
return new Error(
`condition for rule ${name} must be "always" or "never", received ${util.inspect(when)}`
)
}

const executableRule = rule as Rule<unknown>
return null
})
.filter((item): item is Error => item instanceof Error)

// eslint-disable-next-line no-shadow
const [valid, message] = await executableRule(parsed, when, value)
if (invalid.length > 0) {
throw new Error(invalid.map((i) => i.message).join('\n'))
}

return {
level,
valid,
name,
message,
}
})
// Validate against all rules
const pendingResults = Object.entries(rulesConfig)
// Level 0 rules are ignored
.filter(([, config]) => !!config && config.length && config[0] > 0)
.map(async (entry) => {
const [name, config] = entry
const [level, when, value] = config! //

const results = (await Promise.all(pendingResults)).filter(
(result): result is LintRuleOutcome => result !== null
)
const rule = allRules.get(name)

const errors = results.filter((result) => result.level === 2 && !result.valid)
const warnings = results.filter((result) => result.level === 1 && !result.valid)
if (!rule) {
throw new Error(`Could not find rule implementation for ${name}`)
}

const valid = errors.length === 0
const executableRule = rule as Rule<unknown>

return {
// eslint-disable-next-line no-shadow
const [valid, message] = await executableRule(parsed, when, value)

return {
level,
valid,
errors,
warnings,
input: buildCommitMesage(parsed),
}
name,
message,
}
})

const results = (await Promise.all(pendingResults)).filter(
(result): result is LintRuleOutcome => result !== null
)

const errors = results.filter((result) => result.level === 2 && !result.valid)
const warnings = results.filter((result) => result.level === 1 && !result.valid)

const valid = errors.length === 0

return {
valid,
errors,
warnings,
input: buildCommitMesage(parsed),
}
}
6 changes: 3 additions & 3 deletions code/code-format-worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
"@rollup/plugin-commonjs": "^21.0.1",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.1.3",
"@types/node": "^17.0.17",
"esbuild": "^0.14.21",
"rollup": "^2.67.2",
"@types/node": "^17.0.10",
"esbuild": "^0.14.12",
"rollup": "^2.65.0",
"rollup-plugin-analyzer": "^4.0.0",
"rollup-plugin-esbuild": "^4.8.2",
"rollup-plugin-terser": "^7.0.2"
Expand Down
2 changes: 1 addition & 1 deletion code/code-format-worker/src/formatter.worker.source.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { workerData } from 'node:worker_threads'
import { parentPort } from 'node:worker_threads'
import { workerData } from 'node:worker_threads'

import { Formatter } from '@atls/code-format'

Expand Down
2 changes: 1 addition & 1 deletion code/code-format/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"prettier": "^2.5.1"
},
"devDependencies": {
"@types/node": "^17.0.17"
"@types/node": "^17.0.10"
},
"publishConfig": {
"main": "dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion code/code-format/src/formatter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as plugin from '@atls/prettier-plugin'

import { readFile } from 'node:fs/promises'
import { writeFile } from 'node:fs/promises'
import { readFile } from 'node:fs/promises'
import { relative } from 'node:path'

import globby from 'globby'
Expand Down
8 changes: 4 additions & 4 deletions code/code-lint-worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
"@rollup/plugin-commonjs": "^21.0.1",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.1.3",
"@types/node": "^17.0.17",
"esbuild": "^0.14.21",
"eslint": "^8.8.0",
"rollup": "^2.67.2",
"@types/node": "^17.0.10",
"esbuild": "^0.14.12",
"eslint": "^8.7.0",
"rollup": "^2.65.0",
"rollup-plugin-analyzer": "^4.0.0",
"rollup-plugin-esbuild": "^4.8.2",
"rollup-plugin-terser": "^7.0.2"
Expand Down
Loading

0 comments on commit 0f464e4

Please sign in to comment.