Skip to content

Commit

Permalink
refactor: Extract some packages from the main repository (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Feb 5, 2024
1 parent c1ecb05 commit ca60700
Show file tree
Hide file tree
Showing 21 changed files with 266 additions and 14 deletions.
8 changes: 8 additions & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @swc/cli

## 0.3.9

### Patch Changes

- a87f28d: Refactoring for @swc/counter
- Updated dependencies [a87f28d]
- @swc/counter@0.1.3

## 0.3.8

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@swc/cli",
"version": "0.3.8",
"version": "0.3.9",
"description": "CLI for the swc project",
"main": "lib/swc/index.js",
"scripts": {
Expand Down Expand Up @@ -46,7 +46,7 @@
},
"dependencies": {
"@mole-inc/bin-wrapper": "^8.0.1",
"@swc/counter": "^0.1.2",
"@swc/counter": "workspace:^",
"commander": "^7.1.0",
"fast-glob": "^3.2.5",
"minimatch": "^9.0.3",
Expand Down
7 changes: 7 additions & 0 deletions packages/counter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @swc/counter

## 0.1.3

### Patch Changes

- a87f28d: Refactoring for @swc/counter
7 changes: 7 additions & 0 deletions packages/counter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @swc/couter

Download counter for swc packages.

This package does not contain any code. It is used solely to track number of downloads of npm packages like `@swc/core` and `@next/swc`. If you are building a huge project using SWC, please consider depending on this package. It will not add any code to your bundle, but it will help us determine the number of users of SWC.

Counting is done by npm, just like other packages.
1 change: 1 addition & 0 deletions packages/counter/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log("download-counter/index.js");
27 changes: 27 additions & 0 deletions packages/counter/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "@swc/counter",
"packageManager": "pnpm@8.6.7",
"main": "index.js",
"version": "0.1.3",
"description": "Downloade counter for the swc project",
"sideEffects": false,
"repository": {
"type": "git",
"url": "git+https://github.com/swc-project/pkgs.git"
},
"publishConfig": {
"registry": "https://registry.npmjs.org/",
"access": "public"
},
"keywords": [
"swc",
"download",
"counter"
],
"author": "강동윤 <kdy1997.dev@gmail.com>",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/swc-project/swc/issues"
},
"homepage": "https://swc.rs"
}
7 changes: 7 additions & 0 deletions packages/css-loader/examples/modules/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# swc-css-loader-css-modules-app

## 1.0.3

### Patch Changes

- Updated dependencies [a87f28d]
- swc-loader@0.2.6

## 1.0.2

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/css-loader/examples/modules/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "swc-css-loader-css-modules-app",
"private": true,
"version": "1.0.2",
"version": "1.0.3",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
8 changes: 8 additions & 0 deletions packages/jest/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @swc/jest

## 0.2.36

### Patch Changes

- a87f28d: Refactoring for @swc/counter
- Updated dependencies [a87f28d]
- @swc/counter@0.1.3

## 0.2.35

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/jest/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@swc/jest",
"version": "0.2.35",
"version": "0.2.36",
"description": "swc integration for jest",
"main": "index.js",
"types": "index.d.ts",
Expand All @@ -27,7 +27,7 @@
},
"dependencies": {
"@jest/create-cache-key-function": "^29.7.0",
"@swc/counter": "^0.1.2",
"@swc/counter": "workspace:^",
"jsonc-parser": "^3.2.0"
},
"devDependencies": {
Expand Down
8 changes: 8 additions & 0 deletions packages/swc-info/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
yarn.lock
node_modules
_/
*.tgz
lib/*.js
tests/*.js
*.d.ts
*.map
10 changes: 10 additions & 0 deletions packages/swc-info/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
examples/
node_modules/
package-lock.json
*.log
.swcrc
.yarn
*.tgz
.dprint.json
out/
tests/
7 changes: 7 additions & 0 deletions packages/swc-info/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# swc-info

## 0.1.16

### Patch Changes

- a87f28d: Refactoring for @swc/counter
9 changes: 9 additions & 0 deletions packages/swc-info/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# swc-info

## Usage

```sh
npx -y swc-info@latest
```

then copy the output to the issue;.
2 changes: 2 additions & 0 deletions packages/swc-info/bin/swc-info.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env node
require("../lib/index.js");
74 changes: 74 additions & 0 deletions packages/swc-info/lib/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import os from "node:os";
import process from "node:process";
import childProcess from "child_process";
import { createRequire } from "node:module";

const localRequire = createRequire(`${process.cwd()}/[eval]`);

function getUniqueCpuNames(): string {
return os
.cpus()
.map((cpu) => cpu.model)
.filter((model, index, models) => models.indexOf(model) === index)
.join(", ");
}

function getBinaryVersion(binaryName: string): string {
try {
return childProcess
.execFileSync(binaryName, ["--version"])
.toString()
.trim();
} catch {
return "N/A";
}
}

function getPackageVersion(packageName: string) {
try {
return localRequire(`${packageName}/package.json`).version;
} catch {
return null;
}
}

function interestingPackage(name: string): string | null {
const version = getPackageVersion(name);
if (version) {
return `${name}: ${version}`;
} else {
return null;
}
}
function interestingPackages(names: string[]): string {
return names.map(interestingPackage).filter(Boolean).join("\n ");
}

console.log(`
Operating System:
Platform: ${os.platform()}
Arch: ${os.arch()}
Machine Type: ${os.machine()}
Version: ${os.version()}
CPU: (${os.cpus().length} cores)
Models: ${getUniqueCpuNames()}
Binaries:
Node: ${process.versions.node}
npm: ${getBinaryVersion("npm")}
Yarn: ${getBinaryVersion("yarn")}
pnpm: ${getBinaryVersion("pnpm")}
Relevant Packages:
@swc/core: ${getPackageVersion("@swc/core") ?? "N/A"}
@swc/helpers: ${getPackageVersion("@swc/helpers") ?? "N/A"}
@swc/types: ${getPackageVersion("@swc/types") ?? "N/A"}
${interestingPackages(["typescript", "next"])}
SWC Config:
output: N/A
.swcrc path: N/A
Next.js info:
output: N/A
`);
35 changes: 35 additions & 0 deletions packages/swc-info/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "swc-info",
"packageManager": "pnpm@8.6.7",
"version": "0.1.16",
"description": "CLI tool to help issue reporting for swc",
"sideEffects": false,
"scripts": {
"build": "tsc",
"prepublishOnly": "yarn build",
"prepack": "yarn build"
},
"repository": {
"type": "git",
"url": "git+https://github.com/swc-project/pkgs.git"
},
"publishConfig": {
"registry": "https://registry.npmjs.org/",
"access": "public"
},
"keywords": [
"swc",
"info",
"cli"
],
"author": "강동윤 <kdy1997.dev@gmail.com>",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/swc-project/swc/issues"
},
"homepage": "https://swc.rs",
"devDependencies": {
"typescript": "^5.2.2"
},
"bin": "bin/swc-info.js"
}
20 changes: 20 additions & 0 deletions packages/swc-info/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"target": "es2019",
"useDefineForClassFields": true,
"module": "commonjs",
"baseUrl": "./",
"paths": {},
"resolveJsonModule": true,
"declaration": true,
"sourceMap": true,
"downlevelIteration": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"rootDir": "."
},
"include": ["lib", "tests"],
"exclude": ["examples"]
}
8 changes: 8 additions & 0 deletions packages/swc-loader/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# swc-loader

## 0.2.6

### Patch Changes

- a87f28d: Refactoring for @swc/counter
- Updated dependencies [a87f28d]
- @swc/counter@0.1.3

## 0.2.5

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/swc-loader/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "swc-loader",
"version": "0.2.5",
"version": "0.2.6",
"description": "Webpack plugin for swc",
"main": "src/index.js",
"repository": "https://github.com/swc-project/pkgs",
Expand All @@ -16,6 +16,6 @@
"webpack": ">=2"
},
"dependencies": {
"@swc/counter": "^0.1.2"
"@swc/counter": "workspace:^"
}
}

0 comments on commit ca60700

Please sign in to comment.