Merge pull request #279 from aminya/vite [skip ci]

This commit is contained in:
Amin Yahyaabadi 2024-09-04 01:17:02 -07:00 committed by GitHub
commit ab36eabc6a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
40 changed files with 3576 additions and 304 deletions

View File

@ -13,6 +13,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true
env:
NODE_OPTIONS: --enable-source-maps
jobs:
Build:
runs-on: ${{ matrix.os }}
@ -200,6 +203,14 @@ jobs:
env:
RUNNER_OS_NAME: ${{ matrix.os }}
- name: Modern Integration Tests
if: ${{ !contains(github.event.head_commit.message, '[skip test]') }}
run: |
node ./dist/modern/setup-cpp.mjs --help
node ./dist/modern/setup-cpp.mjs --gcc true --cmake true
env:
RUNNER_OS_NAME: ${{ matrix.os }}
- name: Setup Node 12
uses: actions/setup-node@v4
with:
@ -214,7 +225,7 @@ jobs:
node-version: 16
- name: Smoke Test Node 16
run: |
node ./dist/modern/setup-cpp.js --help
node ./dist/modern/setup-cpp.mjs --help
Docker:
name: Docker-${{ matrix.container.image }}

View File

@ -1,2 +0,0 @@
const { buildTerserOptions } = require("terser-config-atomic/dist/builder")
module.exports = buildTerserOptions(process.env.NODE_ENV, undefined, true)

2
.terserrc.mjs Normal file
View File

@ -0,0 +1,2 @@
import { buildTerserOptions } from "terser-config-atomic/dist/builder.js"
export default buildTerserOptions(process.env.NODE_ENV, undefined, true)

View File

@ -100,7 +100,7 @@ inputs:
runs:
using: "node20"
main: "dist/modern/setup-cpp.js"
main: "dist/modern/setup-cpp.mjs"
branding:
icon: "award"

View File

@ -62,6 +62,7 @@ words:
- libdw
- libstdc
- libtinfo
- liuli
- memoizee
- msbuild
- msvc

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
dist/modern/assets/hdi-CLiriP2M.mjs vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

3
dist/modern/setup-cpp.mjs vendored Normal file

File diff suppressed because one or more lines are too long

1
dist/modern/setup-cpp.mjs.map vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -6,8 +6,8 @@
"license": "Apache-2.0",
"author": "Amin Yahyaabadi",
"main": "dist/legacy/setup-cpp.js",
"modern": "./dist/modern/setup-cpp.js",
"source": "./src/main.ts",
"modern": "./dist/modern/setup-cpp.mjs",
"source": "./src/setup-cpp.ts",
"bin": {
"setup-cpp": "dist/legacy/setup-cpp.js"
},
@ -26,12 +26,13 @@
"tsconfig.json"
],
"scripts": {
"build": "turbo build && run-p lint.root.tsc build.parcel copy.matchers && run-s build.babel",
"build": "turbo build && run-p lint.root.tsc build.parcel build.vite && run-p build.babel copy.json",
"build.parcel": "cross-env NODE_ENV=production parcel build",
"build.babel": "babel ./dist --out-dir dist --plugins @upleveled/babel-plugin-remove-node-prefix --plugins @babel/plugin-transform-private-methods --compact --no-babelrc --source-maps true",
"build.vite": "cross-env NODE_ENV=production vite build",
"build.babel": "babel ./dist/legacy --out-dir ./dist/legacy --plugins @upleveled/babel-plugin-remove-node-prefix --plugins @babel/plugin-transform-private-methods --compact --no-babelrc --source-maps true",
"bump": "ncu -u -x numerous,execa,prettier,@types/node,eslint,@types/eslint && pnpm update && pnpx typesync && pnpm run clean",
"clean": "shx rm -rf ./dist ./packages/*/dist ./exe ./.parcel-cache && shx mkdir -p ./dist/legacy ./dist/modern ./dist/modern ",
"copy.matchers": "shx cp ./src/*/*.json ./dist/legacy/ && shx cp ./dist/legacy/*.json ./dist/modern",
"copy.json": "shx cp ./src/*/*.json ./dist/legacy/ && shx cp ./dist/legacy/*.json ./dist/modern",
"dev.parcel": "cross-env NODE_ENV=development parcel watch",
"dev.packages": "turbo dev",
"dev": "run-p dev.packages dev.parcel",
@ -63,6 +64,7 @@
"@babel/plugin-transform-private-methods": "^7.25.4",
"@biomejs/biome": "^1.8.3",
"@iarna/toml": "^2.2.5",
"@liuli-util/vite-plugin-node": "^0.9.0",
"@octokit/core": "^6.1.2",
"@octokit/openapi-types": "^22.2.0",
"@octokit/plugin-paginate-rest": "^11.3.3",
@ -117,6 +119,7 @@
"prettier-config-atomic": "^4.0.0",
"readme-md-generator": "^1.0.0",
"retry-as-promised": "^7.0.4",
"rollup": "^4.21.2",
"safe-stable-stringify": "^2.5.0",
"semver": "7.6.3",
"setup-apt": "workspace:*",
@ -124,6 +127,7 @@
"setup-python": "github:aminya/setup-python#a783db655c6e40317e2c0c96f9d162d9c9f4a751",
"shx": "0.3.4",
"simple-update-notifier": "^2.0.0",
"terser": "^5.31.6",
"terser-config-atomic": "^1.0.0",
"time-delta": "github:aminya/time-delta#69d91a41cef28e569be9a2991129f5f7d1f0d00e",
"ts-node": "^10.9.2",
@ -133,6 +137,8 @@
"ubuntu-version": "^2.0.0",
"untildify-user": "workspace:*",
"util.types": "^0.0.2",
"vite": "^5.4.3",
"vite-plugin-node": "^3.1.0",
"web-streams-polyfill": "^4.0.0",
"which": "^4.0.0"
},
@ -219,15 +225,6 @@
"includeNodeModules": true,
"optimize": true,
"outputFormat": "commonjs"
},
"modern": {
"context": "node",
"engines": {
"node": ">=20.x"
},
"includeNodeModules": true,
"optimize": true,
"outputFormat": "commonjs"
}
},
"pnpm": {

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,5 @@
import path from "path"
import { fileURLToPath } from "url"
import { execaSync } from "execa"
import { chmod } from "fs/promises"
import { addExeExt, join } from "patha"
@ -7,6 +9,8 @@ import { cleanupTmpDir, setupTmpDir, testBin } from "../../utils/tests/test-help
import { getVersion } from "../../versions/versions.js"
import { setupGcc } from "../gcc.js"
const dirname = typeof __dirname === "string" ? __dirname : path.dirname(fileURLToPath(import.meta.url))
jest.setTimeout(3000000)
describe("setup-gcc", () => {
let directory: string
@ -55,13 +59,13 @@ describe("setup-gcc", () => {
expect(process.env.CXX?.includes("g++")).toBeTruthy()
// test compilation
const file = join(__dirname, "main.cpp")
const main_exe = join(__dirname, addExeExt("main"))
execaSync("g++", [file, "-o", main_exe], { cwd: __dirname })
const file = join(dirname, "main.cpp")
const main_exe = join(dirname, addExeExt("main"))
execaSync("g++", [file, "-o", main_exe], { cwd: dirname })
if (process.platform !== "win32") {
await chmod(main_exe, "755")
}
execaSync(main_exe, { cwd: __dirname, stdio: "inherit" })
execaSync(main_exe, { cwd: dirname, stdio: "inherit" })
})
afterAll(async () => {

View File

@ -1,7 +1,8 @@
import { addEnv, addPath } from "envosman"
import path from "path"
import { fileURLToPath } from "url"
import { GITHUB_ACTIONS } from "ci-info"
import { error, info, warning } from "ci-log"
import { addEnv, addPath } from "envosman"
import { type ExecaReturnValue, execa } from "execa"
import { readdir } from "fs/promises"
import { pathExists } from "path-exists"
@ -23,11 +24,13 @@ import { setupDnfPack } from "../utils/setup/setupDnfPack.js"
import { setupPacmanPack } from "../utils/setup/setupPacmanPack.js"
import { compareVersion } from "../utils/setup/version.js"
const dirname = typeof __dirname === "string" ? __dirname : path.dirname(fileURLToPath(import.meta.url))
async function getGccPackageInfo(version: string, platform: NodeJS.Platform, arch: string): Promise<PackageInfo> {
switch (platform) {
case "win32": {
const mingwAssets = await loadGitHubAssetList(
join(__dirname, "github_brechtsanders_winlibs_mingw.json"),
join(dirname, "github_brechtsanders_winlibs_mingw.json"),
)
const asset = matchAsset(
mingwAssets,
@ -287,8 +290,8 @@ async function getGccCmdVersion(binDir: string, givenVersion: string) {
// try to find the gcc exe in the bin dir
const files = (await readdir(binDir)).sort(
(exe1, exe2) => {
const version1 = exe1.match(/^gcc-?(.*)(\.exe)?$/)?.[1] || ""
const version2 = exe2.match(/^gcc-?(.*)(\.exe)?$/)?.[1] || ""
const version1 = exe1.match(/^gcc-?(.*)(\.exe)?$/)?.[1] ?? ""
const version2 = exe2.match(/^gcc-?(.*)(\.exe)?$/)?.[1] ?? ""
return compareVersion(version1, version2)
},
)
@ -321,7 +324,7 @@ async function getGccCmdVersion(binDir: string, givenVersion: string) {
}
async function addGccLoggingMatcher() {
const matcherPath = join(__dirname, "gcc_matcher.json")
const matcherPath = join(dirname, "gcc_matcher.json")
if (!(await pathExists(matcherPath))) {
return warning("the gcc_matcher.json file does not exist in the same folder as setup-cpp.js")
}

View File

@ -1,3 +1,5 @@
import path from "path"
import { fileURLToPath } from "url"
import { info } from "ci-log"
import { execa } from "execa"
import { addExeExt, join } from "patha"
@ -17,6 +19,8 @@ import { setupPacmanPack } from "../utils/setup/setupPacmanPack.js"
import { addVPrefix, removeVPrefix } from "../utils/setup/version.js"
import { getVersion } from "../versions/versions.js"
const dirname = typeof __dirname === "string" ? __dirname : path.dirname(fileURLToPath(import.meta.url))
function getDownloadKcovPackageInfo(version: string): PackageInfo {
return {
url: `https://github.com/SimonKagstrom/kcov/releases/download/${version}/kcov-amd64.tar.gz`,
@ -55,7 +59,7 @@ async function buildKcov(file: string, dest: string) {
// apply gcc13.patch
try {
if (which.sync("patch", { nothrow: true }) !== null) {
const patch = join(__dirname, "gcc13.patch")
const patch = join(dirname, "gcc13.patch")
await execa("patch", ["-N", "-p1", "-i", patch], { cwd: out, stdio: "inherit" })
} else {
info("`patch` not found, skipping gcc13.patch, kcov may not build on gcc 13")

View File

@ -1,3 +1,5 @@
import path from "path"
import { fileURLToPath } from "url"
import * as io from "@actions/io"
import { execaSync } from "execa"
import { chmod } from "fs/promises"
@ -10,6 +12,8 @@ import { getVersion } from "../../versions/versions.js"
import { setupClangFormat, setupClangTools, setupLLVM } from "../llvm.js"
import { VERSIONS, getLinuxUrl, getUrl } from "../llvm_url.js"
const dirname = typeof __dirname === "string" ? __dirname : path.dirname(fileURLToPath(import.meta.url))
jest.setTimeout(400000)
async function testUrl(version: string) {
const [specificVersion, url] = await getSpecificVersionAndUrl(VERSIONS, process.platform, version, getUrl)
@ -98,13 +102,13 @@ describe("setup-llvm", () => {
expect(process.env.CXX?.includes("clang++")).toBeTruthy()
// test compilation
const file = join(__dirname, "main.cpp")
const main_exe = join(__dirname, addExeExt("main"))
execaSync("clang++", [file, "-o", main_exe], { cwd: __dirname })
const file = join(dirname, "main.cpp")
const main_exe = join(dirname, addExeExt("main"))
execaSync("clang++", [file, "-o", main_exe], { cwd: dirname })
if (process.platform !== "win32") {
await chmod(main_exe, "755")
}
execaSync(main_exe, { cwd: __dirname, stdio: "inherit" })
execaSync(main_exe, { cwd: dirname, stdio: "inherit" })
})
it("should setup clang-format", async () => {

View File

@ -1,4 +1,5 @@
import { delimiter } from "path"
import path, { delimiter } from "path"
import { fileURLToPath } from "url"
import { GITHUB_ACTIONS } from "ci-info"
import { info, warning } from "ci-log"
import { addEnv } from "envosman"
@ -17,6 +18,8 @@ import { getVersion } from "../versions/versions.js"
import { LLVMPackages, setupLLVMApt } from "./llvm_installer.js"
import { getLLVMPackageInfo } from "./llvm_url.js"
const dirname = typeof __dirname === "string" ? __dirname : path.dirname(fileURLToPath(import.meta.url))
export async function setupLLVM(version: string, setupDir: string, arch: string): Promise<InstallationInfo> {
const installationInfo = await setupLLVMWithoutActivation(version, setupDir, arch)
await activateLLVM(installationInfo.installDir ?? setupDir)
@ -146,7 +149,7 @@ export async function activateLLVM(directory: string) {
async function addLLVMLoggingMatcher() {
if (GITHUB_ACTIONS) {
const matcherPath = join(__dirname, "llvm_matcher.json")
const matcherPath = join(dirname, "llvm_matcher.json")
if (!(await pathExists(matcherPath))) {
return warning("the llvm_matcher.json file does not exist in the same folder as setup-cpp.js")
}

View File

@ -1,13 +1,16 @@
import path from "path"
import { fileURLToPath } from "url"
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import { GITHUB_ACTIONS } from "ci-info"
import { error, info, warning } from "ci-log"
import { findVcvarsall, vsversion_to_versionnumber } from "msvc-dev-cmd/lib.js"
import { pathExists } from "path-exists"
import { join } from "patha"
import { setupChocoPack } from "../utils/setup/setupChocoPack.js"
import { setupVCVarsall } from "../vcvarsall/vcvarsall.js"
import { error, info, warning } from "ci-log"
import { pathExists } from "path-exists"
const dirname = typeof __dirname === "string" ? __dirname : path.dirname(fileURLToPath(import.meta.url))
type MSVCVersion = "2022" | "17.0" | "2019" | "16.0" | "2017" | "15.0" | "2015" | "14.0" | "2013" | "12.0" | string
@ -72,7 +75,7 @@ export async function setupMSVC(
}
async function addMSVCLoggingMatcher() {
const matcherPath = join(__dirname, "msvc_matcher.json")
const matcherPath = join(dirname, "msvc_matcher.json")
if (!(await pathExists(matcherPath))) {
return warning("the msvc_matcher.json file does not exist in the same folder as setup-cpp.js")
}

View File

@ -1,13 +1,16 @@
import { findPyPyVersion } from "setup-python/src/find-pypy.js"
import { useCpythonVersion } from "setup-python/src/find-python.js"
import path from "path"
import { fileURLToPath } from "url"
import { debug } from "@actions/core"
import { GITHUB_ACTIONS } from "ci-info"
import { info, warning } from "ci-log"
import { pathExists } from "path-exists"
import { join } from "patha"
import { findPyPyVersion } from "setup-python/src/find-pypy.js"
import { useCpythonVersion } from "setup-python/src/find-python.js"
import { IS_MAC } from "setup-python/src/utils.js"
const dirname = typeof __dirname === "string" ? __dirname : path.dirname(fileURLToPath(import.meta.url))
function isPyPyVersion(versionSpec: string) {
return versionSpec.startsWith("pypy")
}
@ -53,7 +56,7 @@ export async function setupActionsPython(version: string, _setupDir: string, arc
}
async function addPythonLoggingMatcher() {
const matcherPath = join(__dirname, "python_matcher.json")
const matcherPath = join(dirname, "python_matcher.json")
if (!(await pathExists(matcherPath))) {
return warning("the python_matcher.json file does not exist in the same folder as setup-cpp.js")
}

View File

@ -21,7 +21,9 @@
"allowImportingTsExtensions": true,
"noEmit": true,
// target Node.js 12 https://node.green/#ES2019
"lib": ["ES2019"],
"lib": [
"ES2019"
],
"target": "ESNext",
"allowJs": true,
"esModuleInterop": true,
@ -36,6 +38,7 @@
"./src",
"./dev/",
"./*.ts",
"jest.config.mjs"
"jest.config.mjs",
"vite.config.mts"
]
}

21
vite.config.mts Normal file
View File

@ -0,0 +1,21 @@
import module from "module"
import { type TerserOptions, defineConfig } from "vite"
import terserRc from "./.terserrc.mjs"
const viteConfig = defineConfig({
build: {
ssr: "./src/setup-cpp.ts",
outDir: "./dist/modern",
target: "node20",
minify: "terser",
terserOptions: terserRc as TerserOptions,
sourcemap: true,
},
ssr: {
target: "node",
noExternal: true,
external: module.builtinModules,
},
})
export default viteConfig