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

ローカルパッケージを作成する #4

Open
wants to merge 18 commits into
base: functions
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
d2c3cd9
ローカルパッケージのpackage.jsonを作成
hiroro-work Oct 20, 2024
f5dee0b
ワークスペースルートからsharedのコマンドを実行できるように
hiroro-work Oct 20, 2024
14d54c2
pnpm shared add -D typescript
hiroro-work Oct 20, 2024
0c436a4
pnpm shared add -D eslint@^8.57.0 @typescript-eslint/eslint-plugin @t…
hiroro-work Oct 20, 2024
0dc9b98
pnpm shared add -D prettier eslint-config-prettier
hiroro-work Oct 20, 2024
7b8f15d
ESLintを自動アップデートから除外
hiroro-work Oct 20, 2024
48841b6
TypeScript/ESLint/Prettierの設定ファイル作成
hiroro-work Oct 20, 2024
4774c73
.gitignoreファイル作成
hiroro-work Oct 20, 2024
60efeea
build/lint/formatコマンドを追加
hiroro-work Oct 20, 2024
e9bd010
pnpm shared add -D firebase firebase-admin
hiroro-work Oct 20, 2024
1c1da73
Firestoreのユーティリティ型を作成する
hiroro-work Oct 20, 2024
d7d63b8
pnpm -w add @local/shared && pnpm functions add @local/shared
hiroro-work Oct 20, 2024
8f000c8
Functionsをデプロイできるように
hiroro-work Oct 20, 2024
f69b71b
Merge branch 'functions' into packages
hiroro-work Oct 20, 2024
d166cb8
Merge branch 'functions' into packages
hiroro-work Oct 20, 2024
55683cf
fix a bit
hiroro-work Oct 20, 2024
b45c822
ローカルパッケージビルド時にアップデートするように
hiroro-work Oct 21, 2024
3dfcf08
predeployでnode_modulesを再作成して.pnpmのキャッシュを削除するように
hiroro-work Oct 21, 2024
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
17 changes: 14 additions & 3 deletions firebase.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"source": "**",
"destination": "/index.html"
}
]
],
"predeploy": ["rm -rf .firebase"]
},
"functions": [
{
Expand All @@ -21,8 +22,18 @@
"*.local"
],
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint",
"npm --prefix \"$RESOURCE_DIR\" run build"
"rm -rf node_modules",
"pnpm install",
"pnpm functions lint",
"pnpm build:shared",
"pnpm shared pack --pack-destination ../../functions",
"pnpm functions add ./local-shared-1.0.0.tgz",
"pnpm functions build"
],
"postdeploy": [
"rm -rf functions/local-shared-1.0.0.tgz",
"pnpm functions remove @local/shared",
"pnpm functions add @local/shared"
]
}
]
Expand Down
1 change: 1 addition & 0 deletions functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
},
"main": "lib/index.js",
"dependencies": {
"@local/shared": "workspace:^",
"firebase-admin": "^12.6.0",
"firebase-functions": "^6.0.1"
},
Expand Down
18 changes: 14 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@
"type": "module",
"scripts": {
"functions": "pnpm --dir functions",
"build": "remix vite:build",
"shared": "pnpm --dir packages/shared",
"build": "pnpm build:shared && remix vite:build",
"build:shared": "pnpm shared build",
"dev": "remix vite:dev",
"lint:hosting": "eslint --ignore-path .gitignore --cache --cache-location ./node_modules/.cache/eslint .",
"stylelint": "stylelint '**/*.css'",
"lint": "pnpm lint:hosting && pnpm stylelint && pnpm functions lint",
"lint:fix": "pnpm lint:hosting --fix && pnpm stylelint --fix && pnpm functions lint:fix",
"format": "prettier --write . && pnpm functions format",
"lint": "pnpm lint:hosting && pnpm stylelint && pnpm functions lint && pnpm shared lint",
"lint:fix": "pnpm lint:hosting --fix && pnpm stylelint --fix && pnpm functions lint:fix && pnpm shared lint:fix",
"format": "prettier --write . && pnpm functions format && pnpm shared format",
"preview": "vite preview",
"typecheck": "tsc",
"deploy:hosting": "pnpm build && firebase deploy --except functions --project default",
"deploy:functions": "pnpm functions deploy:default"
},
"dependencies": {
"@local/shared": "workspace:^",
"@remix-run/node": "^2.13.1",
"@remix-run/react": "^2.13.1",
"isbot": "^4",
Expand Down Expand Up @@ -54,5 +57,12 @@
},
"volta": {
"node": "20.17.0"
},
"pnpm": {
"updateConfig": {
"ignoreDependencies": [
"eslint"
]
}
}
}
56 changes: 56 additions & 0 deletions packages/shared/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
root: true,
env: {
browser: true,
es2021: true,
node: true,
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
],
overrides: [
{
env: {
node: true,
},
files: ['.eslintrc.{js,cjs}'],
parserOptions: {
sourceType: 'script',
},
},
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: ['tsconfig.json', 'tsconfig.dev.json'],
},
plugins: ['@typescript-eslint', 'import'],
rules: {
'import/order': [
'error',
{
groups: [
'builtin',
'external',
'internal',
'parent',
'sibling',
'index',
'object',
'type',
],
alphabetize: { order: 'asc' },
},
],
'@typescript-eslint/consistent-type-imports': [
'error',
{ prefer: 'type-imports' },
],
'@typescript-eslint/no-unused-vars': [
'warn',
{ argsIgnorePattern: '^_' },
],
},
};
2 changes: 2 additions & 0 deletions packages/shared/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
dist/
10 changes: 10 additions & 0 deletions packages/shared/.prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/** @type {import("prettier").Config} */
module.exports = {
// NOTE: 書籍にコードを載せやすくするためにprintWidthを短めに設定してます
printWidth: 76,
singleQuote: true,
jsxSingleQuote: true,
semi: true,
trailingComma: 'all',
bracketSpacing: true,
};
29 changes: 29 additions & 0 deletions packages/shared/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "@local/shared",
"type": "module",
"private": true,
"version": "1.0.0",
"description": "",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "tsc",
"lint": "eslint --ignore-path .gitignore .",
"lint:fix": "pnpm lint --fix",
"format": "prettier --write ."
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^8.10.0",
"@typescript-eslint/parser": "^8.10.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.31.0",
"firebase": "^10.14.1",
"firebase-admin": "^12.6.0",
"prettier": "^3.3.3",
"typescript": "^5.6.3"
}
}
1 change: 1 addition & 0 deletions packages/shared/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './types/index.js';
6 changes: 6 additions & 0 deletions packages/shared/src/types/firebase.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { Timestamp as ClientTimestamp } from 'firebase/firestore';
import type { Timestamp as AdminTimestamp } from 'firebase-admin/firestore';

export type WithId<Data> = Data & { id: string };

export type Timestamp = ClientTimestamp | AdminTimestamp;
1 change: 1 addition & 0 deletions packages/shared/src/types/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './firebase.js';
3 changes: 3 additions & 0 deletions packages/shared/tsconfig.dev.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"include": [".eslintrc.cjs", ".prettierrc.cjs"]
}
13 changes: 13 additions & 0 deletions packages/shared/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"target": "ES2017",
"module": "NodeNext",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"declaration": true,
"outDir": "./dist"
},
"include": ["src"]
}
Loading