Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
deps: update dev dependencies (#301)
Browse files Browse the repository at this point in the history
  • Loading branch information
noahnu authored Apr 18, 2023
1 parent 2d4abb0 commit 18c3f1c
Show file tree
Hide file tree
Showing 20 changed files with 448 additions and 759 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
--changeset-ignore-patterns '**/*.test.ts' \
--conventional-changelog-config @tophat/conventional-changelog-config \
--git-base-branch origin/${{ github.base_ref }} \
--prepend-changelog ${{ env.ARTIFACT_DIR }}/CHANGELOG.md \
--changelog-filename ${{ env.ARTIFACT_DIR }}/CHANGELOG.md \
--force-write-change-files
changelog_body=$(cat ${{ env.ARTIFACT_DIR }}/CHANGELOG.md)
changelog_body="${changelog_body//'%'/'%25'}"
Expand Down
2 changes: 1 addition & 1 deletion .yarn/sdks/eslint/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint",
"version": "8.36.0-sdk",
"version": "8.38.0-sdk",
"main": "./lib/api.js",
"type": "commonjs"
}
2 changes: 1 addition & 1 deletion .yarn/sdks/prettier/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "prettier",
"version": "2.2.1-sdk",
"version": "2.8.7-sdk",
"main": "./index.js",
"type": "commonjs"
}
2 changes: 1 addition & 1 deletion .yarn/sdks/typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typescript",
"version": "4.9.5-sdk",
"version": "5.0.3-sdk",
"main": "./lib/typescript.js",
"type": "commonjs"
}
29 changes: 14 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,28 @@
"clean": "rm -rf packages/*/lib"
},
"devDependencies": {
"@commitlint/cli": "^17.2.0",
"@monodeploy/plugin-github": "^0.9.5",
"@commitlint/cli": "^17.6.1",
"@monodeploy/plugin-github": "^1.0.0",
"@tophat/commit-utils-core": "^1.0.0",
"@tophat/commitizen-adapter": "^1.0.2",
"@tophat/commitlint-config": "^1.0.2",
"@tophat/conventional-changelog-config": "^1.0.1",
"@tophat/eslint-config": "^6.0.1",
"@tophat/eslint-config": "^7.0.0",
"@types/fs-extra": "^9.0.1",
"@types/glob": "^7.1.1",
"@types/jest": "^29.5.0",
"@types/node": "^18.11.9",
"@types/yargs": "^16.0.0",
"@typescript-eslint/eslint-plugin": "^5.54.1",
"@typescript-eslint/parser": "^5.43.0",
"@yarnpkg/sdks": "^3.0.0-rc.40",
"codecov": "^3.6.1",
"@typescript-eslint/eslint-plugin": "^5.59.0",
"@typescript-eslint/parser": "^5.59.0",
"@yarnpkg/sdks": "^3.0.0-rc.42",
"commitizen": "^4.0.3",
"commitlint": "^11.0.0",
"cosmiconfig": "^7.0.0",
"eslint": "^8.36.0",
"eslint": "^8.38.0",
"eslint-config-prettier": "^8.8.0",
"eslint-import-resolver-node": "^0.3.7",
"eslint-import-resolver-typescript": "^3.5.3",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^27.2.1",
"eslint-plugin-jsx-a11y": "^6.7.1",
Expand All @@ -56,17 +55,17 @@
"eslint-plugin-react-hooks": "^4.6.0",
"fs-extra": "^9.0.0",
"glob": "^7.1.6",
"husky": "^8.0.2",
"husky": "^8.0.3",
"jest": "^29.5.0",
"jest-junit": "^14.0.1",
"lint-staged": "^13.0.3",
"jest-junit": "^16.0.0",
"lint-staged": "^13.2.1",
"memfs": "^3.1.1",
"minimatch": "^3.0.4",
"monodeploy": "^3.7.5",
"monodeploy": "^4.0.0",
"prettier": "^2.8.7",
"ts-jest": "^29.0.3",
"ts-jest": "^29.1.0",
"ts-node": "^10.9.1",
"typescript": "4.9.5"
"typescript": "5.0.3"
},
"config": {
"commitizen": {
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"main": "lib/index.js",
"bin": {
"rvg": "lib/bin.js"
}
},
"types": "lib/index.d.ts"
},
"dependencies": {
"@react-vector-graphics/core": "workspace:^0.4.2",
Expand Down
3 changes: 2 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/",
"main": "lib/index.js"
"main": "lib/index.js",
"types": "lib/index.d.ts"
},
"dependencies": {
"@svgr/core": "^6",
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ const normalizePluginParams = (
return { ...prevParams, ...codeOrParams }
}

export const run = async ({
export async function run<Options = Record<string, unknown>>({
config,
logger = getLogger(),
}: {
config: Config
config: Config<Options>
logger?: Logger
}): Promise<void> => {
}): Promise<void> {
logger.info('options:', config.options)
const pluginParams: PluginParams[] = [{} as PluginParams]
for (const plugin of getPlugins(config)) {
for (const plugin of getPlugins(config as Config)) {
logger.info('plugin:', plugin)
const [pluginFn, pluginConfig] = await Promise.all([
resolvePlugin(plugin),
Expand Down
3 changes: 2 additions & 1 deletion packages/plugin-assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/",
"main": "lib/index.js"
"main": "lib/index.js",
"types": "lib/index.d.ts"
},
"dependencies": {
"@react-vector-graphics/utils": "workspace:^0.1.1",
Expand Down
1 change: 1 addition & 0 deletions packages/plugin-assets/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './constants'
export type { PluginAssetsOptions } from './types'
export { run as default } from './main'
14 changes: 8 additions & 6 deletions packages/plugin-assets/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as glob from 'glob'

import { OPTIONS, STATE } from './constants'

import type { PluginAssetsOptions } from './types'
import type {
Logger,
NamingScheme,
Expand Down Expand Up @@ -77,28 +78,29 @@ const writeComponent = (params: {
}

export const run: Plugin = async (code, config, state, logger) => {
const options: Partial<PluginAssetsOptions> = config.options ?? {}

if (code) {
const opts = {
assetFile: state[STATE.FILE_PATH],
code,
// @ts-expect-error componentFiles is added to state
componentFiles: state[STATE.COMPONENT_FILES] ?? {},
componentName: state[STATE.COMPONENT_NAME],
fileExt: config.options?.[OPTIONS.FILE_EXT],
fileExt: options?.[OPTIONS.FILE_EXT],
logger,
outputPath: config.options?.[OPTIONS.OUTPUT_PATH],
outputPath: options?.[OPTIONS.OUTPUT_PATH],
}
// @ts-expect-error TODO
writeComponent(opts)
return { code, state: state as State }
} else {
if (!config.options?.[OPTIONS.GLOB_PATTERN]) {
if (!options?.[OPTIONS.GLOB_PATTERN]) {
throw new Error('Invariant violation. Missing glob pattern.')
}
return findAssets({
// @ts-expect-error Args need to be pre-validated
globPattern: config.options[OPTIONS.GLOB_PATTERN],
nameScheme: config.options?.[OPTIONS.NAME_SCHEME] as NamingScheme,
globPattern: options?.[OPTIONS.GLOB_PATTERN],
nameScheme: options?.[OPTIONS.NAME_SCHEME] as NamingScheme,
state,
})
}
Expand Down
6 changes: 6 additions & 0 deletions packages/plugin-assets/src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export type PluginAssetsOptions = {
'assets/fileExt': string
'assets/globPattern': string
'assets/nameScheme': string
'assets/outputPath': string
}
3 changes: 2 additions & 1 deletion packages/plugin-github/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/",
"main": "lib/index.js"
"main": "lib/index.js",
"types": "lib/index.d.ts"
},
"dependencies": {
"@octokit/rest": "^18.0.1",
Expand Down
30 changes: 14 additions & 16 deletions packages/plugin-github/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
const ns = (s: TemplateStringsArray): string => `github/${s}`

export const OPTIONS = {
API: ns`api`,
BASE: ns`base`,
COMMIT_CREATE_PATTERN: ns`commitCreate`,
COMMIT_DELETE_PATTERN: ns`commitDelete`,
COMMIT_UPDATE_PATTERN: ns`commitUpdate`,
API: 'github/api',
BASE: 'github/base',
COMMIT_CREATE_PATTERN: 'github/commitCreate',
COMMIT_DELETE_PATTERN: 'github/commitDelete',
COMMIT_UPDATE_PATTERN: 'github/commitUpdate',
FOLDER_PATH: 'github/folderPath',
HEAD: 'github/head',
OWNER: 'github/owner',
REPO: 'github/repo',
FILE_EXT: 'assets/fileExt', // @react-vector-graphics/plugin-assets
FOLDER_PATH: ns`folderPath`,
GLOB_PATTERN: 'assets/globPattern', // @react-vector-graphics/plugin-assets
HEAD: ns`head`,
NAME_SCHEME: 'assets/nameScheme', // @react-vector-graphics/plugin-assets
OUTPUT_PATH: 'assets/outputPath', // @react-vector-graphics/plugin-assets
OWNER: ns`owner`,
REPO: ns`repo`,
}
} as const

export const STATE = {
COMPONENT_FILES: 'assets/componentFiles', // @react-vector-graphics/plugin-assets
COMPONENT_NAME: 'componentName', // @svgr/plugin-jsx
COMPONENT_NAME_OLD: ns`componentNameOld`,
DIFF_TYPE: ns`diffType`,
COMPONENT_NAME_OLD: 'github/componentNameOld',
DIFF_TYPE: 'github/diffType',
FILE_PATH: 'filePath', // @svgr/plugin-jsx
}
} as const

export const STATUSES = {
ADDED: 'added',
MODIFIED: 'modified',
REMOVED: 'removed',
RENAMED: 'renamed',
}
} as const

export const COMMIT_MESSAGE_PLACEHOLDER = '${message}'

Expand Down
1 change: 1 addition & 0 deletions packages/plugin-github/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './constants'
export { run as default } from './main'
export type { PluginGitHubOptions } from './types'
29 changes: 16 additions & 13 deletions packages/plugin-github/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@ import { OPTIONS, STATE } from './constants'
import findAssets from './findAssets'
import writeComponent from './writeComponent'

import type { PluginGitHubOptions } from './types'
import type { NamingScheme, Plugin, State } from '@react-vector-graphics/types'

export const run: Plugin = async (code, config, state, logger) => {
const options: Partial<PluginGitHubOptions> = config.options ?? {}

const github = {
api: config.options?.[OPTIONS.API],
base: config.options?.[OPTIONS.BASE],
head: config.options?.[OPTIONS.HEAD],
owner: config.options?.[OPTIONS.OWNER],
repo: config.options?.[OPTIONS.REPO],
api: options?.[OPTIONS.API],
base: options?.[OPTIONS.BASE],
head: options?.[OPTIONS.HEAD],
owner: options?.[OPTIONS.OWNER],
repo: options?.[OPTIONS.REPO],
}
const sharedArgs = {
folderPath: config.options?.[OPTIONS.FOLDER_PATH],
folderPath: options?.[OPTIONS.FOLDER_PATH],
github,
}
if (code) {
Expand All @@ -22,17 +25,17 @@ export const run: Plugin = async (code, config, state, logger) => {
assetFile: state[STATE.FILE_PATH as keyof State],
code,
commitMessagePatterns: {
create: config.options?.[OPTIONS.COMMIT_CREATE_PATTERN],
delete: config.options?.[OPTIONS.COMMIT_DELETE_PATTERN],
update: config.options?.[OPTIONS.COMMIT_UPDATE_PATTERN],
create: options?.[OPTIONS.COMMIT_CREATE_PATTERN],
delete: options?.[OPTIONS.COMMIT_DELETE_PATTERN],
update: options?.[OPTIONS.COMMIT_UPDATE_PATTERN],
},
componentFiles: state[STATE.COMPONENT_FILES as keyof State] ?? {},
componentName: state[STATE.COMPONENT_NAME as keyof State],
componentNameOld: state[STATE.COMPONENT_NAME_OLD as keyof State],
diffType: state[STATE.DIFF_TYPE as keyof State],
fileExt: config.options?.[OPTIONS.FILE_EXT],
fileExt: options?.[OPTIONS.FILE_EXT],
logger,
outputPath: config.options?.[OPTIONS.OUTPUT_PATH],
outputPath: options?.[OPTIONS.OUTPUT_PATH],
}
// @ts-expect-error TODO
await writeComponent(opts)
Expand All @@ -41,8 +44,8 @@ export const run: Plugin = async (code, config, state, logger) => {
return findAssets({
...sharedArgs,
// @ts-expect-error Args need to be pre-validated
globPattern: config.options?.[OPTIONS.GLOB_PATTERN],
nameScheme: config.options?.[OPTIONS.NAME_SCHEME] as NamingScheme,
globPattern: options?.[OPTIONS.GLOB_PATTERN],
nameScheme: options?.[OPTIONS.NAME_SCHEME] as NamingScheme,
state,
})
}
Expand Down
18 changes: 18 additions & 0 deletions packages/plugin-github/src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { Octokit } from '@octokit/rest'

export type PluginGitHubOptions = {
'github/api': Octokit

'github/base': string
'github/commitCreate'?: string
'github/commitDelete'?: string
'github/commitUpdate'?: string
'github/folderPath': string
'github/head': string
'github/owner': string
'github/repo': string
'assets/fileExt': string
'assets/globPattern': string
'assets/nameScheme': string
'assets/outputPath': string
}
7 changes: 4 additions & 3 deletions packages/plugin-github/tests/mocks.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { NAMING_SCHEME } from '@react-vector-graphics/utils'

import { OPTIONS, STATE, STATUSES } from '../src'
import { OPTIONS, type PluginGitHubOptions, STATE, STATUSES } from '../src'
import { toBase64 } from '../src/utils'

import type { State } from '@svgr/core'

export const mockSVG = '<svg>mock</svg>'

export const mockState: Partial<State> = {
// @ts-expect-error todo
[STATE.COMPONENT_FILES]: {
'README.md': '## mockIcon\n\nmock usage notes',
},
Expand Down Expand Up @@ -119,8 +120,8 @@ export const mockGithubApi = {
},
}

export const mockOptions = {
[OPTIONS.API]: {},
export const mockOptions: PluginGitHubOptions = {
[OPTIONS.API]: {} as any,
[OPTIONS.BASE]: 'master',
[OPTIONS.FILE_EXT]: 'js',
[OPTIONS.FOLDER_PATH]: 'packages/mock-package',
Expand Down
7 changes: 5 additions & 2 deletions packages/types/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import type { ConfigPlugin, Config as CoreConfig, State } from '@svgr/core'

export type Config = Omit<CoreConfig, 'plugins'> & {
options?: Record<string, unknown>
export type Config<Options = Record<string, unknown>> = Omit<
CoreConfig,
'plugins'
> & {
options?: Options
plugins?: (ConfigPlugin | Plugin)[]
}
/** @deprecated Use Config instead. */
Expand Down
Loading

0 comments on commit 18c3f1c

Please sign in to comment.