Movatterモバイル変換


[0]ホーム

URL:


Skip to content
Search Gists
Sign in Sign up

Instantly share code, notes, and snippets.

@azu
azu /migrate-to-pnpm.ts
CreatedApril 2, 2025 00:16
migrate to pnpm from npm/yarn
#!/usr/bin/env node --experimental-strip-types
// # npm/yarn を pnpm に移行するスクリプト
// ## 制限
// Node.jsのコアパッケージのみを利用する
// - fsのglob
// https://nodejs.org/api/fs.html#fspromisesglobpattern-options
// - util.parseArgv
// https://nodejs.org/api/util.html#utilparseargsconfig
// ## 変更箇所

次のコマンドで、tj-actionsのリポジトリの一覧を取得できる。

$ gh repo list tj-actions --json "name,owner"[  {    "name": "glob",    "owner": {
import*astsfrom"typescript";
constgetLineTextFromFilePosition=(
file:ts.SourceFile,
{ line, character}:ts.LineAndCharacter,
):string=>{
constlines=file.getFullText().split("\n");
returnlines[line]?.slice(character)??"";
};
exportconstrequireComment={
meta:{
type:"suggestion",
docs:{
description:"useEffectにはコメントでの説明が必須です。",
},
schema:[],
messages:{
requireCommentOnUseEffect: `useEffectにはコメントでの説明が必須です。
@azu
azu /pnpm-up.sh
Last activeJanuary 5, 2025 13:31
`pnpm --recursive update --interactive --latest` for pnpm catalogs. pnpm + fzf + yq
# Update pnpm catalog with interactive
# pnpm catalog: https://pnpm.io/ja/catalogs
# fzf: https://github.com/junegunn/fzf
# yq: https://github.com/kislyuk/yq
selected_cataglogs=$(pnpm outdated --recursive --json| jq -r'to_entries[] | .key + ": " + .value.current + " → " + .value.latest'| fzf --multi)
echo$selected_cataglogs|whileread line;do
pkg_name=$(echo"$line"| cut -d: -f1)
pkg_version=$(echo"$line"| cut -d'' -f4)
echo"Update$pkg_name to$pkg_version"
yq -i".catalog += {\"$pkg_name\":\"$pkg_version\"}" pnpm-workspace.yaml
@azu
azu /playwright.md
Last activeAugust 16, 2024 09:57
Playwright v1.44.0...v1.46.0
@azu
azu /next-font.md
CreatedJuly 29, 2024 15:36
next/fontの実装メモ

https://github.com/vercel/next.js/blob/037783445324a85d04675524c941df21b3f4fbb5/packages/font/src/google

  1. next/fontの関数からパラメータを組み立ててhttps://fonts.googleapis.com/css2?family=xxx に対してリクエスト
  1. ダウンロードしたCSSのsrc: url(...) を抜き出してwebfontファイルを保存
  1. ダウンロードしたCSSのsrc: url(...) を保存したファイルパスへ書き換え
@azu
azu /README.md
Last activeFebruary 2, 2025 14:23
Node.jsのTypeScriptサポートについて
@azu
azu /createEnv.ts
Last activeJuly 1, 2024 01:20
Type Safe env.ts
exporttypeBaseEnvRecord=Record<
string,
{
value:string|undefined;
required:boolean;
defaultValue?:string;
}
>;
exporttypeReturnTypeOfCreateEnv<TextendsBaseEnvRecord>={
// If the value is required, it should be a string, otherwise it should be a string or undefined
@azu
azu /tsconfig.json
CreatedJune 22, 2024 03:12
base
{
// ベースのtsconfigは決められたカテゴリのみを設定する
// それ以外は、プロジェクトごとに設定する
// https://www.typescriptlang.org/tsconfig/#compilerOptions
"compilerOptions": {
// incrementalビルドは特別にデフォルトで有効にする
"incremental":true,
// # JavaScript Support
"allowJs":false,
// # Type Checking
NewerOlder

[8]ページ先頭

©2009-2025 Movatter.jp