Skip to content

Commit

Permalink
🚚 将 denokit 中的一些可迁移成node平台的代码,迁移到nodekit上
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaubee committed Oct 12, 2024
1 parent d02fa76 commit 77bdca3
Show file tree
Hide file tree
Showing 20 changed files with 512 additions and 165 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.npm
.pnpm
.import_map.*
3 changes: 2 additions & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"workspace": [
"flow",
"util",
"denokit"
"denokit",
"nodekit"
],
"exclude": [
".npm"
Expand Down
36 changes: 35 additions & 1 deletion deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 0 additions & 19 deletions denokit/deno.json

This file was deleted.

3 changes: 2 additions & 1 deletion denokit/package.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"private": true
"private": true,
"description": "一个面向 deno 开发者专门打造的工具集,因为 deno 对 node 的兼容性,所以这里只包含 deno 专有的部分,其余请参考 @gaubee/nodekit"
}
20 changes: 11 additions & 9 deletions denokit/src/dnt_monorepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import fs from "node:fs";
import node_path from "node:path";
import { build, emptyDir } from "@deno/dnt";
import { iter_map_not_null } from "@gaubee/util/collections";
import { globToRegExp } from "jsr:@std/path@1/glob-to-regexp";
import { $, normalize } from "./shell.ts";
import { readJson, writeJson, writeYaml } from "./config_file.ts";
import { globToRegExp } from "@std/path";
import { $ } from "@gaubee/nodekit/shell";
import { normalizeFilePath } from "@gaubee/nodekit/path";
import { readJson, writeJson, writeYaml } from "@gaubee/nodekit/config_file";
import { isGlob } from "@std/path";
import { deepMerge } from "@std/collections";
// import type { str_replace_start } from "@gaubee/util/string";
const createResolver = (baseDir: string) => (...paths: string[]) => normalize(node_path.resolve(baseDir, ...paths));
const createResolver = (baseDir: string) => (...paths: string[]) =>
normalizeFilePath(node_path.resolve(baseDir, ...paths));

/**
* 将一个 deno-monorepo 编译成 pnpm monorepo
Expand All @@ -26,9 +28,9 @@ export const dntMonorepo = async (
keepTempImportMapJson?: boolean;
} = {},
): Promise<void> => {
const rootDir = normalize(options.rootDir ?? Deno.cwd());
const rootDir = normalizeFilePath(options.rootDir ?? Deno.cwd());
const resolveRootDir = createResolver(rootDir);
const npmDir = normalize(options.npmDir ?? resolveRootDir(".npm"));
const npmDir = normalizeFilePath(options.npmDir ?? resolveRootDir(".npm"));
const resolveNpmDir = createResolver(npmDir);
const rootDenoJson = readJson<any>(resolveRootDir("deno.json"), () =>
readJson(resolveRootDir("deno.jsonc"), () => {
Expand All @@ -46,9 +48,9 @@ export const dntMonorepo = async (
const nodeDir = resolveNpmDir(packageName);
const resolveNodeDir = createResolver(nodeDir);
const denoJson = readJson(resolveDenoDir("deno.json"), () => readJson(resolveDenoDir("deno.jsonc")));
const packageJson = readJson(resolveDenoDir("package.json"), () => ({}));
const packageJson = readJson<any>(resolveDenoDir("package.json"), () => ({}));
return {
alias: normalize(node_path.relative(rootDir, denoDir)),
alias: normalizeFilePath(node_path.relative(rootDir, denoDir)),
name: denoJson.name as string,
version: denoJson.version as string,
denoDir,
Expand Down Expand Up @@ -211,7 +213,7 @@ export const dntMonorepo = async (
}

for (const workspace of workspaces) {
if (aliasFilter(workspace.alias)) {
if (workspace.packageJson.private != true && aliasFilter(workspace.alias)) {
console.log(`%cstart building %c${workspace.alias}`, "color:gray", "color:green");
await buildPackage(workspace, improt_map_json_path);
}
Expand Down
2 changes: 2 additions & 0 deletions denokit/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./dnt_monorepo.ts";
export * from "@gaubee/nodekit";
134 changes: 0 additions & 134 deletions denokit/src/shell.ts

This file was deleted.

2 changes: 2 additions & 0 deletions flow/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# @gaubee/flow

启发于 kotlin 的 flow,针对 js/ts 开发人员设计的接口,通常可以作为一个事件管理器

## [docs 文档](https://jsr.io/@gaubee/flow/doc)

**install:**
Expand Down
5 changes: 5 additions & 0 deletions nodekit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# @gaubee/nodekit

一个面向 node 开发者专门打造的工具集,专门解决开发工具脚本时的常见需求,尽可能不重复造轮子。

## [docs 文档](https://jsr.io/@gaubee/nodekit/doc)
18 changes: 18 additions & 0 deletions nodekit/deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "@gaubee/nodekit",
"version": "0.1.0",
"exports": {
"./config_file": "./src/config_file.ts",
"./fs": "./src/fs.ts",
"./ignore": "./src/ignore.ts",
"./path": "./src/path.ts",
"./shell": "./src/shell.ts",
".": "./src/index.ts"
},
"imports": {
"@std/fmt": "jsr:@std/fmt@^1.0.2",
"@std/jsonc": "jsr:@std/jsonc@^1.0.1",
"@std/path": "jsr:@std/path@^1.0.6",
"@std/yaml": "jsr:@std/yaml@^1.0.5"
}
}
4 changes: 4 additions & 0 deletions nodekit/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"description": "一个面向 node 开发者专门打造的工具集,专门解决开发工具脚本时的常见需求,尽可能不重复造轮子。",
"dependencies": { "ignore": "^6.0.2", "minimatch": "^10.0.1" }
}
File renamed without changes.
Loading

0 comments on commit 77bdca3

Please sign in to comment.