Skip to content

Commit

Permalink
chore(deps): updates
Browse files Browse the repository at this point in the history
  • Loading branch information
morlay committed Mar 30, 2024
1 parent 289650d commit b755460
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 114 deletions.
Binary file modified bun.lockb
Binary file not shown.
4 changes: 2 additions & 2 deletions nodedevpkg/monobundle/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@innoai-tech/monobundle",
"version": "0.13.4",
"version": "0.13.5",
"monobundle": {
"exports": {
".": "./src/index.ts",
Expand All @@ -16,7 +16,7 @@
"@rollup/plugin-node-resolve": "^15.2.3",
"browserslist": "^4.23.0",
"chalk": "^5.3.0",
"esbuild": "^0.20.1",
"esbuild": "^0.20.2",
"globby": "^14.0.1",
"js-yaml": "^4.1.0",
"minimatch": "^9.0.3",
Expand Down
24 changes: 13 additions & 11 deletions nodedevpkg/monobundle/src/autoExternal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ export const collectDeps = async (project: Project, localPkg: Package) => {
const packageJSONs = await globby(
workspaces.map((b) => `${b}/package.json`),
{
cwd: project.root
}
cwd: project.root,
},
);

for (const f of packageJSONs) {
let pkg = JSON.parse(
String(await readFile(join(`${project.root}`, f)))
String(await readFile(join(`${project.root}`, f))),
) as Package;

// localPkg may be changed
Expand All @@ -80,7 +80,7 @@ export const createAutoExternal = async (
opts: {
logger?: ReturnType<typeof import("./log").createLogger>;
sideDeps?: string[];
}
},
) => {
const logger = opts.logger;
const sideDeps = opts.sideDeps || [];
Expand All @@ -90,7 +90,7 @@ export const createAutoExternal = async (
return false;
}
return sideDeps.some(
(glob) => pkgName === glob || minimatch(pkgName, glob)
(glob) => pkgName === glob || minimatch(pkgName, glob),
);
};

Expand Down Expand Up @@ -123,7 +123,7 @@ export const createAutoExternal = async (

const unused = {
deps: {} as { [k: string]: boolean },
peerDeps: {} as { [k: string]: boolean }
peerDeps: {} as { [k: string]: boolean },
};

for (const d of dep) {
Expand Down Expand Up @@ -152,7 +152,7 @@ export const createAutoExternal = async (
external(
id: string,
importer: string | undefined,
isResolved: boolean
isResolved: boolean,
) {
if (
typeof opts.external === "function" &&
Expand All @@ -167,7 +167,9 @@ export const createAutoExternal = async (

if (!(id.startsWith(".") || id.startsWith("/"))) {
const isDep = [...dep.keys()].some((d) => id.startsWith(d));
const isBuiltIn = builtins.some((b) => id.startsWith(b));
const isBuiltIn =
id.startsWith("@nodelib/") ||
builtins.some((b) => id.startsWith(b));

if (isDep) {
usedPkgs.add(id);
Expand All @@ -182,7 +184,7 @@ export const createAutoExternal = async (
collector.add(id);

logger?.danger(
`"${id}" is not in dependencies or peerDependencies, and will be bundled.`
`"${id}" is not in dependencies or peerDependencies, and will be bundled.`,
);
}
}
Expand All @@ -191,9 +193,9 @@ export const createAutoExternal = async (
}

return false;
}
},
};
}
},
};
};

Expand Down
71 changes: 36 additions & 35 deletions nodedevpkg/monobundle/src/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,35 @@ import { get, pick } from "@innoai-tech/lodash";
import { readFile, writeFile } from "fs/promises";
import { globby } from "globby";
import type { Project } from "./pm";
import {
writeFormattedJsonFile
} from "./util";
import { writeFormattedJsonFile } from "./util";

const imlFromPackageJSON = (rpath: string, pkg: any) => {
return join(rpath, `${pkg.name.replace("/", "__")}.iml`);
};

const patchRootPackage = async (
project: Project,
pkgs: { [k: string]: any }
pkgs: { [k: string]: any },
) => {
await writeFile(
join(project.root, ".idea/modules.xml"),
`<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
${Object.entries(pkgs).map(([dir, pkg]) => {
const filename = join(
"$PROJECT_DIR$",
imlFromPackageJSON(relative(project.root, dir), pkg)
);
return `<module fileurl="file://${filename}" filepath="${filename}" />`;
}).join("\n")}
${Object.entries(pkgs)
.map(([dir, pkg]) => {
const filename = join(
"$PROJECT_DIR$",
imlFromPackageJSON(relative(project.root, dir), pkg),
);
return `<module fileurl="file://${filename}" filepath="${filename}" />`;
})
.join("\n")}
</modules>
</component>
</project>
`
`,
);
};

Expand All @@ -44,7 +44,7 @@ const orderKeys = <T extends {}>(o: T) => {
"dependencies",
"peerDependencies",
"devDependencies",
...Object.keys(o).sort()
...Object.keys(o).sort(),
];

return pick(o, orderedKeys);
Expand All @@ -55,19 +55,19 @@ const patchMonoPackage = async (
monoRoot: string,
directory: string,
pkg: any,
rootPkg: any
rootPkg: any,
) => {
const defaultScripts = project.pm.defaults().scripts;

const scripts = {
...(pkg.scripts || {})
...(pkg.scripts || {}),
};

if (get(pkg, ["monobundle"])) {
scripts.lint = get(
pkg,
["monobundle", "pipeline", "lint"],
defaultScripts.lint
defaultScripts.lint,
);
scripts.build =
get(pkg, ["monobundle", "pipeline", "build"], defaultScripts.build) ||
Expand All @@ -80,14 +80,15 @@ const patchMonoPackage = async (
: undefined;
}


await writeFile(join(monoRoot, ".gitignore"), `
await writeFile(
join(monoRoot, ".gitignore"),
`
.turbo/
target/
dist/
*.mjs
*.d.ts
`
`,
);

await writeFormattedJsonFile(
Expand All @@ -99,17 +100,17 @@ dist/
license: "MIT",
repository: rootPkg.repository
? {
...rootPkg.repository,
directory
}
...rootPkg.repository,
directory,
}
: undefined,
publishConfig:
!pkg.private && rootPkg.publishConfig
? {
...rootPkg.publishConfig
}
: undefined
})
...rootPkg.publishConfig,
}
: undefined,
}),
);
};

Expand All @@ -131,17 +132,17 @@ export const addImiFile = async (monoRoot: string, pkg: any) => {
<excludeFolder url="file://$MODULE_DIR$/.build" />
<excludeFolder url="file://$MODULE_DIR$/dist" />
${
isCueMod
? `
isCueMod
? `
<excludeFolder url="file://$MODULE_DIR$/cue.mod/gen" />
<excludeFolder url="file://$MODULE_DIR$/cue.mod/pkg" />
`
: ""
}
: ""
}
</content>
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>`
</module>`,
);
};

Expand All @@ -155,12 +156,12 @@ export const bootstrap = async (project: Project) => {
const packageJsonFiles = await globby(
[
`${project.root}/package.json`,
...workspaces.map((p) => `${p}/package.json`)
...workspaces.map((p) => `${p}/package.json`),
],
{
cwd: project.root,
absolute: true
}
absolute: true,
},
);

const packages: { [k: string]: any } = {};
Expand All @@ -179,7 +180,7 @@ export const bootstrap = async (project: Project) => {
monoRoot,
rpath,
packageJSON,
packages[""]
packages[""],
);
}

Expand Down
Loading

0 comments on commit b755460

Please sign in to comment.