forked from swc-project/swc
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into content-tag-merge-ups…
…tream-main-2024-11-12
- Loading branch information
Showing
19,396 changed files
with
1,640,964 additions
and
1,569,999 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: "Configure Node.js" | ||
description: "Sets Node.js up for CI" | ||
inputs: | ||
node-version: | ||
description: "Node version to install" | ||
required: false | ||
default: "20" | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Install Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ inputs.node-version }} | ||
cache: "yarn" | ||
|
||
- name: Enable corepack | ||
shell: bash | ||
run: corepack enable | ||
|
||
- name: Install dependencies | ||
shell: bash | ||
run: yarn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: "Git tag release" | ||
description: "Tags a release" | ||
inputs: | ||
version: | ||
description: "The version" | ||
required: true | ||
ssh-private-key: | ||
description: "The SSH private key" | ||
required: true | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
ref: "main" | ||
|
||
- uses: ./.github/actions/setup-node | ||
|
||
- name: Install git-cliff | ||
uses: taiki-e/install-action@v2 | ||
with: | ||
tool: [email protected] | ||
|
||
- name: Install cargo-edit | ||
uses: taiki-e/install-action@v2 | ||
with: | ||
tool: [email protected] | ||
|
||
- name: "Setup jq" | ||
uses: dcarbone/install-jq-action@v2 | ||
with: | ||
version: "1.7" | ||
force: true | ||
|
||
- uses: webfactory/[email protected] | ||
with: | ||
ssh-private-key: ${{ inputs.ssh-private-key }} | ||
|
||
- name: Create git tag commit | ||
shell: bash | ||
run: | | ||
./scripts/publish.sh ${{ inputs.version }} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "swc-bot", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"private": true, | ||
"devDependencies": { | ||
"@types/node": "^17.0.17", | ||
"ts-node": "^10.5.0", | ||
"typescript": "^4.5.5" | ||
}, | ||
"dependencies": { | ||
"@octokit/rest": "^18.12.0", | ||
"yaml": "^1.10.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { exec } from "child_process"; | ||
import { getCommitSha } from "../util/git"; | ||
import * as fs from "fs"; | ||
import { promisify } from "util"; | ||
import * as path from "path"; | ||
|
||
const execAsync = promisify(exec); | ||
|
||
const writeFile = promisify(fs.writeFile); | ||
|
||
(async () => { | ||
const sha = await getCommitSha(); | ||
const filePath = path.resolve( | ||
__dirname, | ||
"../../../../crates/swc_core/src/__diagnostics.rs" | ||
); | ||
|
||
await writeFile( | ||
filePath, | ||
`pub(crate) static PKG_SEMVER_FALLBACK: &str = include_str!(concat!(env!("OUT_DIR"), "/core_pkg_version.txt")); | ||
pub(crate) static GIT_SHA: &str = "${sha}";`, | ||
"utf-8" | ||
); | ||
|
||
await execAsync(`git config --global user.email "[email protected]"`); | ||
await execAsync(`git config --global user.name "SWC Bot"`); | ||
|
||
// we won't push, it's only to avoid dirty check for the publish | ||
await execAsync(`git add ${filePath}`); | ||
await execAsync(`git commit -m 'build(swc/core): bump sha'`); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// npx ts-node .github/bot/src/nightly-version.ts $version | ||
|
||
import { octokit, owner, repo } from "./util/octokit"; | ||
|
||
function addZ(n: number) { | ||
return n < 10 ? "0" + n : "" + n; | ||
} | ||
|
||
async function main() { | ||
// Default to the core version in packages/core/package.json | ||
const coreVersion = require("../../../packages/core/package.json").version; | ||
|
||
const latest: string = process.argv[2] || coreVersion; | ||
|
||
process.stderr.write(`Previous version: ${latest}\n`); | ||
|
||
// Bump patch version | ||
|
||
const [major, minor, patch] = latest.split("-")[0].split(".").map(Number); | ||
|
||
// Nightly version after 1.2.3 is 1.2.4-nightly-20211020.1 | ||
// Nightly version after 1.2.3-nightly-20211020.1 is 1.2.3-nightly-20211020.2 | ||
|
||
const version = `${major}.${minor}.${patch}`; | ||
// Nightly version | ||
|
||
const date = new Date(); | ||
|
||
const year = date.getFullYear(); | ||
const month = date.getMonth() + 1; | ||
const day = date.getDate(); | ||
|
||
const datePart = `${year}${addZ(month)}${addZ(day)}`; | ||
|
||
const base = `v${version}-nightly-${datePart}`; | ||
let idx = 1; | ||
let nightlyVersion = `${base}.${idx}`; | ||
|
||
// Check if the nightly version already exists, using octokit and git tags | ||
|
||
const { data: tagData } = await octokit.repos.listTags({ | ||
owner, | ||
repo, | ||
order: "desc", | ||
}); | ||
const tags = tagData.map((tag) => tag.name); | ||
while (tags.includes(nightlyVersion)) { | ||
idx += 1; | ||
nightlyVersion = `${base}.${idx}`; | ||
} | ||
process.stderr.write(`Nightly version: ${nightlyVersion}\n`); | ||
|
||
process.stdout.write(`version=${nightlyVersion.substring(1)}\n`); | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { exec } from "child_process"; | ||
import { type Stream } from "stream"; | ||
|
||
async function streamToString(stream: Stream): Promise<string> { | ||
const chunks: Buffer[] = []; | ||
return new Promise((resolve, reject) => { | ||
stream.on("data", (chunk) => chunks.push(Buffer.from(chunk))); | ||
stream.on("error", (err) => reject(err)); | ||
stream.on("end", () => resolve(Buffer.concat(chunks).toString("utf8"))); | ||
}); | ||
} | ||
|
||
export async function getTitleOfLatestCommit(): Promise<string> { | ||
const { stdout } = await exec("git log -1 --pretty=%B"); | ||
|
||
const msg = await streamToString(stdout!); | ||
|
||
const s = msg.trim(); | ||
|
||
return s.split("\n")[0]; | ||
} | ||
|
||
export async function getCommitSha(): Promise<string> { | ||
const { stdout } = exec("git rev-parse HEAD"); | ||
|
||
const msg = await streamToString(stdout!); | ||
|
||
const s = msg.trim(); | ||
|
||
return s; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Octokit } from "@octokit/rest"; | ||
|
||
export const octokit = new Octokit({ | ||
auth: process.env.GITHUB_TOKEN, | ||
}); | ||
|
||
export const owner = "swc-project"; | ||
export const repo = "swc"; | ||
|
||
export function getCurrentPrNumber(): number { | ||
const ref = process.env.GITHUB_REF; | ||
if (!ref) { | ||
throw new Error( | ||
`Cannot get current pr number because GITHUB_REF is not set` | ||
); | ||
} | ||
console.log(`GITHUB_REF: ${ref}`); | ||
|
||
if (ref.startsWith(`refs/pull/`) && ref.endsWith("/merge")) { | ||
const pr = ref.substring(10, ref.length - 6); | ||
return parseInt(pr); | ||
} else { | ||
throw new Error( | ||
`Cannot get current pr number because GITHUB_REF is not 'refs/pull/:prNumber/merge'` | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
{ | ||
"compilerOptions": { | ||
/* Visit https://aka.ms/tsconfig.json to read more about this file */ | ||
/* Projects */ | ||
// "incremental": true, /* Enable incremental compilation */ | ||
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ | ||
// "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */ | ||
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */ | ||
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ | ||
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ | ||
/* Language and Environment */ | ||
"target": "es2019" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, | ||
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ | ||
// "jsx": "preserve", /* Specify what JSX code is generated. */ | ||
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ | ||
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ | ||
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */ | ||
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ | ||
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */ | ||
// "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */ | ||
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ | ||
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ | ||
/* Modules */ | ||
"module": "commonjs" /* Specify what module code is generated. */, | ||
// "rootDir": "./", /* Specify the root folder within your source files. */ | ||
// "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ | ||
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ | ||
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ | ||
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ | ||
// "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */ | ||
// "types": [], /* Specify type package names to be included without being referenced in a source file. */ | ||
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ | ||
// "resolveJsonModule": true, /* Enable importing .json files */ | ||
// "noResolve": true, /* Disallow `import`s, `require`s or `<reference>`s from expanding the number of files TypeScript should add to a project. */ | ||
/* JavaScript Support */ | ||
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */ | ||
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ | ||
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */ | ||
/* Emit */ | ||
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ | ||
// "declarationMap": true, /* Create sourcemaps for d.ts files. */ | ||
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ | ||
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */ | ||
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */ | ||
// "outDir": "./", /* Specify an output folder for all emitted files. */ | ||
// "removeComments": true, /* Disable emitting comments. */ | ||
// "noEmit": true, /* Disable emitting files from a compilation. */ | ||
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ | ||
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */ | ||
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ | ||
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ | ||
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ | ||
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ | ||
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ | ||
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ | ||
// "newLine": "crlf", /* Set the newline character for emitting files. */ | ||
// "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */ | ||
// "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */ | ||
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ | ||
// "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */ | ||
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */ | ||
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ | ||
/* Interop Constraints */ | ||
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ | ||
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ | ||
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */, | ||
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ | ||
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */, | ||
/* Type Checking */ | ||
"strict": true /* Enable all strict type-checking options. */, | ||
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */ | ||
// "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */ | ||
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ | ||
// "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */ | ||
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ | ||
// "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */ | ||
// "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */ | ||
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ | ||
// "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */ | ||
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */ | ||
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ | ||
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ | ||
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ | ||
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ | ||
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ | ||
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */ | ||
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ | ||
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ | ||
/* Completeness */ | ||
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ | ||
"skipLibCheck": true /* Skip type checking all .d.ts files. */ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// @ts-check | ||
const { defineConfig } = require("eslint-define-config"); | ||
|
||
module.exports = defineConfig({ | ||
root: true, | ||
extends: [ | ||
"eslint:recommended", | ||
"plugin:n/recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
], | ||
parser: "@typescript-eslint/parser", | ||
parserOptions: { | ||
sourceType: "module", | ||
ecmaVersion: 2021, | ||
}, | ||
rules: { | ||
eqeqeq: ["warn", "always", { null: "never" }], | ||
"no-debugger": ["error"], | ||
"no-empty": ["warn", { allowEmptyCatch: true }], | ||
"no-process-exit": "off", | ||
"no-useless-escape": "off", | ||
"prefer-const": [ | ||
"warn", | ||
{ | ||
destructuring: "all", | ||
}, | ||
], | ||
"n/no-missing-import": "off", // doesn't like ts imports | ||
"n/no-process-exit": "off", | ||
"@typescript-eslint/no-explicit-any": "off", // we use any in some places | ||
}, | ||
}); |
Oops, something went wrong.