Skip to content

Commit

Permalink
chore: update deps (PlasmoHQ#690)
Browse files Browse the repository at this point in the history
* Remove prettier sort fork

* chore: upgrade deps, remove custom fork of prettier sorter

* chore: bump dependencies

* update examples

* Packup
  • Loading branch information
louisgv authored Jul 17, 2023
1 parent 462e804 commit 888b601
Show file tree
Hide file tree
Showing 93 changed files with 649 additions and 694 deletions.
7 changes: 4 additions & 3 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ requests should be made against.

To develop locally:

1. Install [pnpm](https://pnpm.io/)
1. Install [pnpm](https://pnpm.io/)
- DO NOT install pnpm a as npm's global dependency, we need pnpm to be able to link directly to your $PATH.
- Recommended installation method is with corepack or with brew (on macOS)
- If installed with brew, you might need to include the pnpm $PATH to your debugger
Expand Down Expand Up @@ -76,12 +76,13 @@ To develop locally:
```

Note: The `create-plasmo` CLI tool is not meant to be run locally.
If you have already linked it, please run
If you have already linked it, please run

```sh
pnpm -g unlink create-plasmo
```
to unlink it.

to unlink it.

## Building

Expand Down
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
[submodule "packages/config"]
path = packages/config
url = https://github.com/PlasmoHQ/plasmo-config.git
[submodule "packages/prettier-plugin-sort-imports"]
path = packages/prettier-plugin-sort-imports
url = https://github.com/PlasmoHQ/prettier-plugin-sort-imports.git
[submodule "api/storage"]
path = api/storage
url = [email protected]:PlasmoHQ/storage.git
Expand Down
17 changes: 0 additions & 17 deletions .prettierrc.cjs

This file was deleted.

31 changes: 31 additions & 0 deletions .prettierrc.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* @type {import('prettier').Options}
*/
export default {
printWidth: 80,
tabWidth: 2,
useTabs: false,
semi: false,
singleQuote: false,
trailingComma: "none",
bracketSpacing: true,
bracketSameLine: true,
plugins: ["@ianvs/prettier-plugin-sort-imports"],
importOrder: [
"<BUILTIN_MODULES>", // Node.js built-in modules
"<THIRD_PARTY_MODULES>", // Imports not matched by other special words or groups.
"", // Empty line
"^@plasmo/(.*)$",
"",
"^@plasmohq/(.*)$",
"",
"^@plasmo-static-common/(.*)$",
"",
"^~(.*)$",
"",
"^[./]",
"",
"__plasmo_import_module__",
"__plasmo_mount_content_script__"
]
}
2 changes: 1 addition & 1 deletion api/messaging/jest.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ const config = {
]
},
testMatch: ["**/*.test.ts"],
verbose: true,
verbose: true
}
export default config
2 changes: 1 addition & 1 deletion api/messaging/src/hook.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useRef, useState } from "react"

import { type MessageName, type PlasmoMessaging, relayMessage } from "./index"
import { relayMessage, type MessageName, type PlasmoMessaging } from "./index"
import { listen as messageListen } from "./message"
import { listen as portListen } from "./port"
import { relay } from "./relay"
Expand Down
4 changes: 3 additions & 1 deletion api/messaging/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ export namespace PlasmoMessaging {
}

export interface PortHook {
<TRequestBody = Record<string, any>, TResponseBody = any>(name: PortName): {
<TRequestBody = Record<string, any>, TResponseBody = any>(
name: PortName
): {
data?: TResponseBody
send: (payload: TRequestBody) => void
listen: <T = TResponseBody>(
Expand Down
2 changes: 1 addition & 1 deletion api/storage
Submodule storage updated 2 files
+0 −17 .prettierrc.cjs
+0 −1 package.json
1 change: 1 addition & 0 deletions cli/create-plasmo/bin/index.mjs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/usr/bin/env node

import "../dist/index.js"
2 changes: 1 addition & 1 deletion cli/create-plasmo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-plasmo",
"version": "0.80.0",
"version": "0.81.0",
"description": "Create Plasmo Framework Browser Extension",
"main": "dist/index.js",
"bin": "bin/index.mjs",
Expand Down
2 changes: 1 addition & 1 deletion cli/create-plasmo/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node
import { argv, exit } from "process"
import { version } from "plasmo/package.json"
import init from "plasmo/src/commands/init"
import { argv, exit } from "process"

import { ErrorMessage } from "@plasmo/constants/error"
import { aLog, eLog } from "@plasmo/utils/logging"
Expand Down
1 change: 1 addition & 0 deletions cli/plasmo/bin/index.mjs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/usr/bin/env node

import "../dist/index.js"
2 changes: 1 addition & 1 deletion cli/plasmo/i18n/README.ja-JP.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pnpm dev

変更したい部分によって、以下のファイルを編集してください。

- ポップアップ → `popup.tsx`
- ポップアップ → `popup.tsx`
- 設定ページ → `options.tsx`
- コンテンツスクリプト → `content.ts`
- バックグランドサービスワーカー → `background.ts`
Expand Down
2 changes: 1 addition & 1 deletion cli/plasmo/index.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { argv, exit } from "process"
import { build, context } from "esbuild"
import fse from "fs-extra"
import { argv, exit } from "process"

const watch = argv.includes("-w")

Expand Down
5 changes: 3 additions & 2 deletions cli/plasmo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "plasmo",
"version": "0.80.0",
"version": "0.81.0",
"description": "The Plasmo Framework CLI",
"publishConfig": {
"types": "dist/type.d.ts"
Expand Down Expand Up @@ -64,11 +64,12 @@
"package-json": "8.1.1",
"process": "0.11.10",
"semver": "7.5.4",
"sharp": "0.32.2",
"sharp": "0.32.3",
"tempy": "3.1.0",
"typescript": "5.1.6"
},
"devDependencies": {
"vue": "3.3.4",
"@plasmo/config": "workspace:*",
"@plasmo/constants": "workspace:*",
"@plasmo/framework-shared": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion cli/plasmo/src/commands/init.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { paramCase } from "change-case"
import { resolve } from "path"
import { cwd } from "process"
import { paramCase } from "change-case"

import { hasFlag } from "@plasmo/utils/flags"
import { ensureWritableAndEmpty } from "@plasmo/utils/fs"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ensureDir, outputFile } from "fs-extra"
import { relative, resolve } from "path"
import { ensureDir, outputFile } from "fs-extra"

import { vLog } from "@plasmo/utils/logging"
import { toPosix } from "@plasmo/utils/path"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { relative, resolve } from "path"
import { camelCase } from "change-case"
import { outputFile } from "fs-extra"
import { relative, resolve } from "path"

import { vLog } from "@plasmo/utils/logging"
import { toPosix } from "@plasmo/utils/path"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { outputFile } from "fs-extra"
import { resolve } from "path"
import { outputFile } from "fs-extra"

import type { CommonPath } from "~features/extension-devtools/common-path"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { join, resolve } from "path"
import { camelCase } from "change-case"
import glob from "fast-glob"
import { outputFile } from "fs-extra"
import { join, resolve } from "path"

import { isWriteable } from "@plasmo/utils/fs"
import { vLog, wLog } from "@plasmo/utils/logging"
Expand Down
4 changes: 2 additions & 2 deletions cli/plasmo/src/features/env/env-config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Forked from https://github.com/vercel/next.js/blob/canary/packages/next-env/index.ts
import { readFile } from "fs/promises"
import { resolve } from "path"
import { constantCase } from "change-case"
import dotenv from "dotenv"
import { expand as dotenvExpand } from "dotenv-expand"
import { readFile } from "fs/promises"
import { resolve } from "path"

import { isFile, isReadable } from "@plasmo/utils/fs"
import { eLog, iLog, vLog } from "@plasmo/utils/logging"
Expand Down
2 changes: 1 addition & 1 deletion cli/plasmo/src/features/env/env-declaration.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { outputFile } from "fs-extra"
import { resolve } from "path"
import { outputFile } from "fs-extra"

import type { PlasmoManifest } from "~features/manifest-factory/base"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { readFile } from "fs/promises"
import type { Node, VariableDeclaration } from "typescript"
import typescript from "typescript"
import typescript, { type Node, type VariableDeclaration } from "typescript"

import type { ManifestContentScript } from "@plasmo/constants"
import { eLog, vLog } from "@plasmo/utils/logging"
Expand Down Expand Up @@ -33,13 +32,16 @@ export const extractContentScriptConfig = async (path: string) => {

const variableDeclarationMap = sourceFile.statements
.filter(isVariableStatement)
.reduce((output, node) => {
node.declarationList.forEachChild((vd: VariableDeclaration) => {
output[vd.name.getText()] = vd.initializer
})

return output
}, {} as Record<string, Node>)
.reduce(
(output, node) => {
node.declarationList.forEachChild((vd: VariableDeclaration) => {
output[vd.name.getText()] = vd.initializer
})

return output
},
{} as Record<string, Node>
)

const configAST = variableDeclarationMap["config"]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { copy, ensureDir } from "fs-extra"
import { basename, resolve } from "path"
import { copy, ensureDir } from "fs-extra"
import sharp from "sharp"

import { find } from "@plasmo/utils/array"
Expand Down
3 changes: 1 addition & 2 deletions cli/plasmo/src/features/extension-devtools/package-file.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { sentenceCase } from "change-case"
import { userInfo } from "os"
import { sentenceCase } from "change-case"
import getPackageJson, { type AbbreviatedVersion } from "package-json"

import type { ExtensionManifestV3 } from "@plasmo/constants"
Expand Down Expand Up @@ -30,7 +30,6 @@ const _generatePackage = async ({
"react-dom": "*"
} as Record<string, string>,
devDependencies: {
"@plasmohq/prettier-plugin-sort-imports": "workspace:*",
"@types/chrome": "*",
"@types/node": "*",
"@types/react": "*",
Expand Down
15 changes: 7 additions & 8 deletions cli/plasmo/src/features/extension-devtools/parse-ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
* Adapted from https://github.com/dword-design/ts-ast-to-literal/blob/master/src/index.js
* Copyright (c) Sebastian Landwehr [email protected], MIT licensed
*/
import type {
ArrayLiteralExpression,
Identifier,
LiteralExpression,
Node,
ObjectLiteralExpression,
PropertyAssignment
import typescript, {
type ArrayLiteralExpression,
type Identifier,
type LiteralExpression,
type Node,
type ObjectLiteralExpression,
type PropertyAssignment
} from "typescript"
import typescript from "typescript"

const { SyntaxKind } = typescript

Expand Down
11 changes: 7 additions & 4 deletions cli/plasmo/src/features/extension-devtools/project-path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,13 @@ export enum WatchReason {
type DirectoryWatchTuple = [WatchReason, string]

const getWatchReasonMap = (paths: string[], reason: WatchReason) =>
paths.reduce((output, path) => {
output[path] = reason
return output
}, {} as Record<string, WatchReason>)
paths.reduce(
(output, path) => {
output[path] = reason
return output
},
{} as Record<string, WatchReason>
)

export const getProjectPath = (
{ sourceDirectory, packageFilePath, assetsDirectory }: CommonPath,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type Event, subscribe } from "@parcel/watcher"
import { subscribe, type Event } from "@parcel/watcher"

import { PARCEL_WATCHER_BACKEND } from "@plasmo/constants/misc"
import { assertUnreachable } from "@plasmo/utils/assert"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { readFile, readdir, rename, stat, writeFile } from "fs/promises"
import { readdir, readFile, rename, stat, writeFile } from "fs/promises"
import { join, resolve } from "path"

const stripFileUnderscore = async (filePath: string) => {
Expand Down
4 changes: 2 additions & 2 deletions cli/plasmo/src/features/extension-devtools/tsconfig.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { outputFile, outputJson } from "fs-extra"
import { readFile } from "fs/promises"
import json5 from "json5"
import { resolve } from "path"
import { outputFile, outputJson } from "fs-extra"
import json5 from "json5"

import { MESSAGING_DECLARATION } from "~features/background-service-worker/bgsw-messaging-declaration"
import { PROCESS_ENV_DECLARATION } from "~features/env/env-declaration"
Expand Down
2 changes: 1 addition & 1 deletion cli/plasmo/src/features/extra/cache-busting.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { emptyDir, ensureDir } from "fs-extra"
import { lstat } from "fs/promises"
import { resolve } from "path"
import { emptyDir, ensureDir } from "fs-extra"

import { isAccessible } from "@plasmo/utils/fs"
import { vLog } from "@plasmo/utils/logging"
Expand Down
4 changes: 2 additions & 2 deletions cli/plasmo/src/features/extra/next-new-tab.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { sentenceCase } from "change-case"
import { copy, emptyDir, readJson, writeJson } from "fs-extra"
import { mkdir } from "fs/promises"
import { resolve } from "path"
import { sentenceCase } from "change-case"
import { copy, emptyDir, readJson, writeJson } from "fs-extra"

import { isAccessible } from "@plasmo/utils/fs"
import { sLog, vLog } from "@plasmo/utils/logging"
Expand Down
2 changes: 1 addition & 1 deletion cli/plasmo/src/features/helpers/create-parcel-bundler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { dirname, join, resolve } from "path"
import ParcelFS from "@parcel/fs"
import ParcelPM from "@parcel/package-manager"
import { emptyDir, ensureDir, readJson, writeJson } from "fs-extra"
import { dirname, join, resolve } from "path"

import { getFlag, hasFlag } from "@plasmo/utils/flags"

Expand Down
Loading

0 comments on commit 888b601

Please sign in to comment.