Skip to content

Commit

Permalink
Update execa to 6.0.0 (#12245)
Browse files Browse the repository at this point in the history
* Update execa

* Fix

* require `execa` directly

* Run `vendors:bundle`

* Run `vendors:bundle`

* Generate dts with considering defautl export

* Remove `vendors-versions.json`
  • Loading branch information
sosukesuzuki committed Feb 12, 2022
1 parent 92e6f44 commit 34fbd09
Show file tree
Hide file tree
Showing 10 changed files with 2,279 additions and 23 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@
"eslint-plugin-regexp": "1.5.1",
"eslint-plugin-unicorn": "40.1.0",
"esm-utils": "3.0.0",
"execa": "5.1.1",
"jest": "27.5.0",
"execa": "6.0.0",
"jest-snapshot-serializer-ansi": "1.0.0",
"jest-snapshot-serializer-raw": "1.2.0",
"jest-watch-typeahead": "1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-website.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import fs from "node:fs/promises";
import fastGlob from "fast-glob";
import prettier from "prettier";
import createEsmUtils from "esm-utils";
import execa from "execa";
import { execa } from "execa";
import {
PROJECT_ROOT,
DIST_DIR,
Expand Down
2 changes: 1 addition & 1 deletion scripts/clean-cspell.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node

import fs from "node:fs/promises";
import execa from "execa";
import { execa } from "execa";

const CSPELL_CONFIG_FILE = new URL("../cspell.json", import.meta.url);
const updateConfig = (config) =>
Expand Down
29 changes: 19 additions & 10 deletions scripts/vendors/bundle-vendors.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,24 @@ async function cleanExistsBundledJS() {
}
}

async function generateDts(vendor) {
const hasDefault = await import(vendor).then((module) =>
Boolean(module.default)
);
await fs.writeFile(
path.join(vendorsDir, `${vendor}.d.ts`),
[
"// This file is generated automatically.",
hasDefault ? `export {default} from "${vendor}";` : null,
`export * from "${vendor}";`,
"",
]
.filter((line) => line !== null)
.join("\n"),
"utf-8"
);
}

async function bundle(vendor, options) {
const outfile = getVendorFilePath(vendor);
if (await fileExists(outfile)) {
Expand All @@ -74,16 +92,7 @@ async function bundle(vendor, options) {
};
await esbuild.build(esbuildOption);

await fs.writeFile(
path.join(vendorsDir, `${vendor}.d.ts`),
[
"// This file is generated automatically.",
`export {default} from "${vendor}";`,
`export * from "${vendor}";`,
"",
].join("\n"),
"utf-8"
);
await generateDts(vendor);
}

async function main() {
Expand Down
287 changes: 286 additions & 1 deletion scripts/vendors/vendor-meta.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion scripts/vendors/vendors.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const vendors = ["string-width", "mem"];
const vendors = ["string-width", "mem", "execa"];

export default vendors;
12 changes: 6 additions & 6 deletions tests/config/install-prettier.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

const path = require("path");
const fs = require("fs");
const execa = require("execa");
const tempy = require("tempy");
const chalk = require("chalk");
const { execaSync } = require("../../vendors/execa.js");

const allowedClients = new Set(["yarn", "npm", "pnpm"]);

Expand Down Expand Up @@ -42,15 +42,15 @@ function cleanUp() {
module.exports = (packageDir) => {
const tmpDir = tempy.directory();
directoriesToClean.add(tmpDir);
const fileName = execa
.sync("npm", ["pack"], { cwd: packageDir })
.stdout.trim();
const fileName = execaSync("npm", ["pack"], {
cwd: packageDir,
}).stdout.trim();
const file = path.join(packageDir, fileName);
const packed = path.join(tmpDir, fileName);
fs.copyFileSync(file, packed);
fs.unlinkSync(file);

execa.sync(client, ["init", "-y"], { cwd: tmpDir });
execaSync(client, ["init", "-y"], { cwd: tmpDir });

let installArguments = [];
switch (client) {
Expand All @@ -67,7 +67,7 @@ module.exports = (packageDir) => {
installArguments = ["add", packed];
}

execa.sync(client, installArguments, { cwd: tmpDir });
execaSync(client, installArguments, { cwd: tmpDir });
fs.unlinkSync(packed);

const installed = path.join(tmpDir, "node_modules/prettier");
Expand Down
2 changes: 2 additions & 0 deletions vendors/execa.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// This file is generated automatically.
export * from "execa";

0 comments on commit 34fbd09

Please sign in to comment.