mirror of
https://github.com/swc-project/swc.git
synced 2024-11-23 00:32:15 +03:00
refactor(cli): Make CLI testable/managable with swc-bump
(#8045)
**Description:** It was hard to maintain CLI because actual logic was in `./bindings`.
This commit is contained in:
parent
2bf935c68b
commit
f717cf21cc
46
.github/workflows/CI.yml
vendored
46
.github/workflows/CI.yml
vendored
@ -244,12 +244,18 @@ jobs:
|
|||||||
- crate: swc_cached
|
- crate: swc_cached
|
||||||
os: ubuntu-latest
|
os: ubuntu-latest
|
||||||
runner: ubuntu-latest
|
runner: ubuntu-latest
|
||||||
|
- crate: swc_cli_impl
|
||||||
|
os: ubuntu-latest
|
||||||
|
runner: ubuntu-latest
|
||||||
- crate: swc_common
|
- crate: swc_common
|
||||||
os: ubuntu-latest
|
os: ubuntu-latest
|
||||||
runner: ubuntu-latest
|
runner: ubuntu-latest
|
||||||
- crate: swc_common
|
- crate: swc_common
|
||||||
os: windows-latest
|
os: windows-latest
|
||||||
runner: windows-latest
|
runner: windows-latest
|
||||||
|
- crate: swc_compiler_base
|
||||||
|
os: ubuntu-latest
|
||||||
|
runner: ubuntu-latest
|
||||||
- crate: swc_config
|
- crate: swc_config
|
||||||
os: ubuntu-latest
|
os: ubuntu-latest
|
||||||
runner: ubuntu-latest
|
runner: ubuntu-latest
|
||||||
@ -590,13 +596,6 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
jest --version && mocha --version
|
jest --version && mocha --version
|
||||||
|
|
||||||
- name: Cache rust artifacts
|
|
||||||
uses: Swatinem/rust-cache@v2
|
|
||||||
if: matrix.settings.crate == 'swc' || matrix.settings.crate == 'swc_plugin_runner'
|
|
||||||
with:
|
|
||||||
shared-key: cargo-test-${{ matrix.settings.crate }}
|
|
||||||
cache-on-failure: true
|
|
||||||
|
|
||||||
- name: Configure execution cache
|
- name: Configure execution cache
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
@ -711,14 +710,6 @@ jobs:
|
|||||||
./scripts/cargo/patch-section.sh >> bindings/Cargo.toml
|
./scripts/cargo/patch-section.sh >> bindings/Cargo.toml
|
||||||
cd bindings && cargo update -p swc_core
|
cd bindings && cargo update -p swc_core
|
||||||
|
|
||||||
- name: Cache
|
|
||||||
uses: actions/cache@v3
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
~/.cargo/
|
|
||||||
**/target/
|
|
||||||
key: ${{ runner.os }}-node-api-test
|
|
||||||
|
|
||||||
- name: Set platform name
|
- name: Set platform name
|
||||||
run: |
|
run: |
|
||||||
export NODE_PLATFORM_NAME=$(node -e "console.log(require('os').platform())")
|
export NODE_PLATFORM_NAME=$(node -e "console.log(require('os').platform())")
|
||||||
@ -749,14 +740,6 @@ jobs:
|
|||||||
node-version: 14
|
node-version: 14
|
||||||
cache: "yarn"
|
cache: "yarn"
|
||||||
|
|
||||||
- name: Cache
|
|
||||||
uses: actions/cache@v3
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
~/.cargo/
|
|
||||||
**/target/
|
|
||||||
key: ${{ runner.os }}-cargo-integration
|
|
||||||
|
|
||||||
- name: Set platform name
|
- name: Set platform name
|
||||||
run: |
|
run: |
|
||||||
export NODE_PLATFORM_NAME=$(node -e "console.log(require('os').platform())")
|
export NODE_PLATFORM_NAME=$(node -e "console.log(require('os').platform())")
|
||||||
@ -833,3 +816,20 @@ jobs:
|
|||||||
- name: (swcpack) example react app
|
- name: (swcpack) example react app
|
||||||
run: |
|
run: |
|
||||||
(cd crates/swc_node_bundler/tests/integration/react && yarn && npx spack)
|
(cd crates/swc_node_bundler/tests/integration/react && yarn && npx spack)
|
||||||
|
|
||||||
|
done:
|
||||||
|
needs:
|
||||||
|
- cargo-fmt
|
||||||
|
- cargo-clippy
|
||||||
|
- cargo-deny
|
||||||
|
- cargo-check
|
||||||
|
- test-wasm
|
||||||
|
- cargo-test
|
||||||
|
- node-test
|
||||||
|
- integration-test
|
||||||
|
if: always()
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Done
|
||||||
|
steps:
|
||||||
|
- run: exit 1
|
||||||
|
if: ${{ always() && (contains(needs.*.result, 'failure') || contains(needs.*.result, 'skipped') || contains(needs.*.result, 'cancelled')) }}
|
||||||
|
123
Cargo.lock
generated
123
Cargo.lock
generated
@ -460,19 +460,20 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap"
|
name = "clap"
|
||||||
version = "3.1.0"
|
version = "3.2.25"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e5f1fea81f183005ced9e59cdb01737ef2423956dac5a6d731b06b2ecfaa3467"
|
checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"atty",
|
"atty",
|
||||||
"bitflags 1.3.2",
|
"bitflags 1.3.2",
|
||||||
"clap_derive",
|
"clap_derive",
|
||||||
|
"clap_lex 0.2.4",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"lazy_static",
|
"once_cell",
|
||||||
"os_str_bytes",
|
|
||||||
"strsim",
|
"strsim",
|
||||||
"termcolor",
|
"termcolor",
|
||||||
"textwrap",
|
"terminal_size 0.2.6",
|
||||||
|
"textwrap 0.16.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -492,14 +493,14 @@ checksum = "2e53afce1efce6ed1f633cf0e57612fe51db54a1ee4fd8f8503d078fe02d69ae"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"anstyle",
|
"anstyle",
|
||||||
"bitflags 1.3.2",
|
"bitflags 1.3.2",
|
||||||
"clap_lex",
|
"clap_lex 0.5.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_derive"
|
name = "clap_derive"
|
||||||
version = "3.1.0"
|
version = "3.2.25"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5fd1122e63869df2cb309f449da1ad54a7c6dfeb7c7e6ccd8e0825d9eb93bb72"
|
checksum = "ae6371b8bdc8b7d3959e9cf7b22d4435ef3e79e138688421ec654acf8c81b008"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"heck 0.4.0",
|
"heck 0.4.0",
|
||||||
"proc-macro-error",
|
"proc-macro-error",
|
||||||
@ -508,6 +509,15 @@ dependencies = [
|
|||||||
"syn 1.0.109",
|
"syn 1.0.109",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap_lex"
|
||||||
|
version = "0.2.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5"
|
||||||
|
dependencies = [
|
||||||
|
"os_str_bytes",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_lex"
|
name = "clap_lex"
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
@ -533,7 +543,7 @@ dependencies = [
|
|||||||
"encode_unicode",
|
"encode_unicode",
|
||||||
"libc",
|
"libc",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"terminal_size",
|
"terminal_size 0.1.17",
|
||||||
"unicode-width",
|
"unicode-width",
|
||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
@ -967,7 +977,7 @@ name = "dbg-swc"
|
|||||||
version = "0.87.46"
|
version = "0.87.46"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"clap 3.1.0",
|
"clap 3.2.25",
|
||||||
"dialoguer",
|
"dialoguer",
|
||||||
"flate2",
|
"flate2",
|
||||||
"rayon",
|
"rayon",
|
||||||
@ -1761,6 +1771,12 @@ dependencies = [
|
|||||||
"testing",
|
"testing",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "json"
|
||||||
|
version = "0.12.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "078e285eafdfb6c4b434e0d31e8cfcb5115b651496faca5749b88fafd4f23bfd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "jsonc-parser"
|
name = "jsonc-parser"
|
||||||
version = "0.21.0"
|
version = "0.21.0"
|
||||||
@ -2009,8 +2025,8 @@ dependencies = [
|
|||||||
"supports-color",
|
"supports-color",
|
||||||
"supports-hyperlinks",
|
"supports-hyperlinks",
|
||||||
"supports-unicode",
|
"supports-unicode",
|
||||||
"terminal_size",
|
"terminal_size 0.1.17",
|
||||||
"textwrap",
|
"textwrap 0.14.2",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"unicode-width",
|
"unicode-width",
|
||||||
]
|
]
|
||||||
@ -2381,9 +2397,6 @@ name = "os_str_bytes"
|
|||||||
version = "6.0.0"
|
version = "6.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64"
|
checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64"
|
||||||
dependencies = [
|
|
||||||
"memchr",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "output_vt100"
|
name = "output_vt100"
|
||||||
@ -2429,12 +2442,30 @@ dependencies = [
|
|||||||
"windows-targets",
|
"windows-targets",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "path-absolutize"
|
||||||
|
version = "3.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e4af381fe79fa195b4909485d99f73a80792331df0625188e707854f0b3383f5"
|
||||||
|
dependencies = [
|
||||||
|
"path-dedot",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "path-clean"
|
name = "path-clean"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ecba01bf2678719532c5e3059e0b5f0811273d94b397088b82e3bd0a78c78fdd"
|
checksum = "ecba01bf2678719532c5e3059e0b5f0811273d94b397088b82e3bd0a78c78fdd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "path-dedot"
|
||||||
|
version = "3.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "07ba0ad7e047712414213ff67533e6dd477af0a4e1d14fb52343e53d30ea9397"
|
||||||
|
dependencies = [
|
||||||
|
"once_cell",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pathdiff"
|
name = "pathdiff"
|
||||||
version = "0.2.1"
|
version = "0.2.1"
|
||||||
@ -3649,6 +3680,28 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "swc_cli_impl"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"atty",
|
||||||
|
"clap 3.2.25",
|
||||||
|
"glob",
|
||||||
|
"path-absolutize",
|
||||||
|
"rayon",
|
||||||
|
"relative-path",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"sourcemap",
|
||||||
|
"swc_core",
|
||||||
|
"tracing",
|
||||||
|
"tracing-chrome",
|
||||||
|
"tracing-futures",
|
||||||
|
"tracing-subscriber",
|
||||||
|
"walkdir",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "swc_common"
|
name = "swc_common"
|
||||||
version = "0.32.1"
|
version = "0.32.1"
|
||||||
@ -5057,6 +5110,16 @@ dependencies = [
|
|||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "terminal_size"
|
||||||
|
version = "0.2.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8e6bf6f19e9f8ed8d4048dc22981458ebcf406d67e94cd422e5ecd73d63b3237"
|
||||||
|
dependencies = [
|
||||||
|
"rustix",
|
||||||
|
"windows-sys 0.48.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "termios"
|
name = "termios"
|
||||||
version = "0.3.3"
|
version = "0.3.3"
|
||||||
@ -5110,6 +5173,15 @@ dependencies = [
|
|||||||
"unicode-width",
|
"unicode-width",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "textwrap"
|
||||||
|
version = "0.16.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d"
|
||||||
|
dependencies = [
|
||||||
|
"terminal_size 0.2.6",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror"
|
name = "thiserror"
|
||||||
version = "1.0.40"
|
version = "1.0.40"
|
||||||
@ -5363,6 +5435,17 @@ dependencies = [
|
|||||||
"syn 2.0.37",
|
"syn 2.0.37",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tracing-chrome"
|
||||||
|
version = "0.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "fcb13184244c7cd22758b79e7c993c515ad67a8e730edcb7e05fe7bcabb283c7"
|
||||||
|
dependencies = [
|
||||||
|
"json",
|
||||||
|
"tracing",
|
||||||
|
"tracing-subscriber",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tracing-core"
|
name = "tracing-core"
|
||||||
version = "0.1.31"
|
version = "0.1.31"
|
||||||
@ -5373,6 +5456,16 @@ dependencies = [
|
|||||||
"valuable",
|
"valuable",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tracing-futures"
|
||||||
|
version = "0.2.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2"
|
||||||
|
dependencies = [
|
||||||
|
"pin-project",
|
||||||
|
"tracing",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tracing-log"
|
name = "tracing-log"
|
||||||
version = "0.1.3"
|
version = "0.1.3"
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
[workspace]
|
[workspace]
|
||||||
members = [
|
members = [
|
||||||
"crates/swc_core",
|
"crates/swc_core",
|
||||||
|
"crates/swc_cli_impl",
|
||||||
"crates/dbg-swc",
|
"crates/dbg-swc",
|
||||||
"crates/jsdoc",
|
"crates/jsdoc",
|
||||||
"crates/binding_macros",
|
"crates/binding_macros",
|
||||||
|
30
bindings/Cargo.lock
generated
30
bindings/Cargo.lock
generated
@ -443,9 +443,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap"
|
name = "clap"
|
||||||
version = "3.2.23"
|
version = "3.2.25"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5"
|
checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"atty",
|
"atty",
|
||||||
"bitflags 1.3.2",
|
"bitflags 1.3.2",
|
||||||
@ -461,9 +461,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_derive"
|
name = "clap_derive"
|
||||||
version = "3.2.18"
|
version = "3.2.25"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65"
|
checksum = "ae6371b8bdc8b7d3959e9cf7b22d4435ef3e79e138688421ec654acf8c81b008"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"heck 0.4.1",
|
"heck 0.4.1",
|
||||||
"proc-macro-error",
|
"proc-macro-error",
|
||||||
@ -1832,9 +1832,9 @@ checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "os_str_bytes"
|
name = "os_str_bytes"
|
||||||
version = "6.5.0"
|
version = "6.5.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ceedf44fb00f2d1984b0bc98102627ce622e083e49a5bacdb3e514fa4238e267"
|
checksum = "4d5d9eb14b174ee9aa2ef96dc2b94637a2d4b6e7cb873c7e171f0c20c6cf3eac"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "overload"
|
name = "overload"
|
||||||
@ -1873,9 +1873,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "path-absolutize"
|
name = "path-absolutize"
|
||||||
version = "3.0.14"
|
version = "3.1.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0f1d4993b16f7325d90c18c3c6a3327db7808752db8d208cea0acee0abd52c52"
|
checksum = "e4af381fe79fa195b4909485d99f73a80792331df0625188e707854f0b3383f5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"path-dedot",
|
"path-dedot",
|
||||||
]
|
]
|
||||||
@ -1888,9 +1888,9 @@ checksum = "ecba01bf2678719532c5e3059e0b5f0811273d94b397088b82e3bd0a78c78fdd"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "path-dedot"
|
name = "path-dedot"
|
||||||
version = "3.0.18"
|
version = "3.1.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9a81540d94551664b72b72829b12bd167c73c9d25fbac0e04fafa8023f7e4901"
|
checksum = "07ba0ad7e047712414213ff67533e6dd477af0a4e1d14fb52343e53d30ea9397"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"once_cell",
|
"once_cell",
|
||||||
]
|
]
|
||||||
@ -2954,6 +2954,16 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "swc_cli"
|
name = "swc_cli"
|
||||||
version = "0.91.80"
|
version = "0.91.80"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"swc_cli_impl",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "swc_cli_impl"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "be08b334a3aedb93d67d50ec07ab4cb2f82930d5f82e3dbe24bb7beaf4f9b5c0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"atty",
|
"atty",
|
||||||
|
@ -14,33 +14,14 @@ name = "swc"
|
|||||||
path = "./src/main.rs"
|
path = "./src/main.rs"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = [
|
||||||
|
"swc_cli_impl/default"
|
||||||
|
]
|
||||||
plugin = [
|
plugin = [
|
||||||
"swc_core/plugin_transform_host_native",
|
"swc_cli_impl/plugin"
|
||||||
"swc_core/plugin_transform_host_native_filesystem_cache",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0.66"
|
anyhow = "1.0.66"
|
||||||
atty = "0.2.14"
|
swc_cli_impl = "0.1.0"
|
||||||
clap = { version = "3.1.0", features = ["derive", "wrap_help"] }
|
|
||||||
glob = "0.3.0"
|
|
||||||
rayon = "1"
|
|
||||||
relative-path = "1.6.1"
|
|
||||||
serde = { version = "1", features = ["derive"] }
|
|
||||||
serde_json = { version = "1", features = ["unbounded_depth"] }
|
|
||||||
sourcemap = "6.2.2"
|
|
||||||
swc_core = { version = "0.83.34", features = [
|
|
||||||
"trace_macro",
|
|
||||||
"common_concurrent",
|
|
||||||
"base_concurrent",
|
|
||||||
] }
|
|
||||||
tracing = "0.1.37"
|
|
||||||
tracing-chrome = "0.5.0"
|
|
||||||
tracing-futures = "0.2.5"
|
|
||||||
tracing-subscriber = { version = "0.3.9", features = ["env-filter"] }
|
|
||||||
walkdir = "2"
|
|
||||||
|
|
||||||
[dependencies.path-absolutize]
|
|
||||||
features = ["once_cell_cache"]
|
|
||||||
version = "3.0.11"
|
|
||||||
|
@ -1,17 +1,3 @@
|
|||||||
use clap::Parser;
|
|
||||||
use commands::{Command, CommandRunner, PluginSubcommand, SwcCliOptions};
|
|
||||||
|
|
||||||
mod commands;
|
|
||||||
mod util;
|
|
||||||
|
|
||||||
fn main() -> anyhow::Result<()> {
|
fn main() -> anyhow::Result<()> {
|
||||||
let command = SwcCliOptions::parse().command;
|
swc_cli_impl::run()
|
||||||
|
|
||||||
match &command {
|
|
||||||
Command::Plugin(PluginSubcommand::New(options)) => options.execute(),
|
|
||||||
Command::Compile(options) => options.execute(),
|
|
||||||
Command::Minify(options) => options.execute(),
|
|
||||||
Command::Bundle(options) => options.execute(),
|
|
||||||
Command::Lint(options) => options.execute(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
39
crates/swc_cli_impl/Cargo.toml
Normal file
39
crates/swc_cli_impl/Cargo.toml
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
[package]
|
||||||
|
authors = ["강동윤 <kdy1997.dev@gmail.com>", "OJ Kwon <kwon.ohjoong@gmail.com>"]
|
||||||
|
description = "Commandline for SWC (Internal crate with implementation)"
|
||||||
|
edition = "2021"
|
||||||
|
include = ["Cargo.toml", "src/**/*.rs"]
|
||||||
|
license = "Apache-2.0"
|
||||||
|
name = "swc_cli_impl"
|
||||||
|
repository = "https://github.com/swc-project/swc.git"
|
||||||
|
version = "0.1.0"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = []
|
||||||
|
plugin = [
|
||||||
|
"swc_core/plugin_transform_host_native",
|
||||||
|
"swc_core/plugin_transform_host_native_filesystem_cache",
|
||||||
|
]
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
anyhow = "1.0.66"
|
||||||
|
atty = "0.2.14"
|
||||||
|
clap = { version = "3.2.25", features = ["derive", "wrap_help"] }
|
||||||
|
glob = "0.3.0"
|
||||||
|
path-absolutize = { version = "3.0.11", features = ["once_cell_cache"] }
|
||||||
|
rayon = "1"
|
||||||
|
relative-path = "1.6.1"
|
||||||
|
serde = { version = "1", features = ["derive"] }
|
||||||
|
serde_json = { version = "1", features = ["unbounded_depth"] }
|
||||||
|
sourcemap = "6.2.2"
|
||||||
|
tracing = "0.1.37"
|
||||||
|
tracing-chrome = "0.5.0"
|
||||||
|
tracing-futures = "0.2.5"
|
||||||
|
tracing-subscriber = { version = "0.3.9", features = ["env-filter"] }
|
||||||
|
walkdir = "2"
|
||||||
|
|
||||||
|
swc_core = { version = "0.83.34", features = [
|
||||||
|
"trace_macro",
|
||||||
|
"common_concurrent",
|
||||||
|
"base_concurrent",
|
||||||
|
], path = "../swc_core" }
|
@ -62,7 +62,7 @@ fn get_name(option: &PluginScaffoldOptions) -> Result<&str> {
|
|||||||
/// Note: this is slim implementation does not support different vcs other than
|
/// Note: this is slim implementation does not support different vcs other than
|
||||||
/// git at the moment.
|
/// git at the moment.
|
||||||
fn write_ignore_file(base_path: &Path) -> Result<()> {
|
fn write_ignore_file(base_path: &Path) -> Result<()> {
|
||||||
let ignore_list: Vec<String> = vec!["/target", "^target/", "target"]
|
let ignore_list: Vec<String> = ["/target", "^target/", "target"]
|
||||||
.iter()
|
.iter()
|
||||||
.map(|v| v.to_string())
|
.map(|v| v.to_string())
|
||||||
.collect();
|
.collect();
|
||||||
@ -149,7 +149,7 @@ impl super::CommandRunner for PluginScaffoldOptions {
|
|||||||
|
|
||||||
// Create `Cargo.toml` file with necessary sections
|
// Create `Cargo.toml` file with necessary sections
|
||||||
fs::write(
|
fs::write(
|
||||||
&path.join("Cargo.toml"),
|
path.join("Cargo.toml"),
|
||||||
format!(
|
format!(
|
||||||
r#"[package]
|
r#"[package]
|
||||||
name = "{}"
|
name = "{}"
|
||||||
@ -190,7 +190,7 @@ swc_core = {{ version = "{}", features = ["ecma_plugin_transform"] }}
|
|||||||
let cargo_config_path = path.join(".cargo");
|
let cargo_config_path = path.join(".cargo");
|
||||||
create_dir_all(&cargo_config_path).context("`create_dir_all` failed")?;
|
create_dir_all(&cargo_config_path).context("`create_dir_all` failed")?;
|
||||||
fs::write(
|
fs::write(
|
||||||
&cargo_config_path.join("config"),
|
cargo_config_path.join("config"),
|
||||||
r#"# These command aliases are not final, may change
|
r#"# These command aliases are not final, may change
|
||||||
[alias]
|
[alias]
|
||||||
# Alias to build actual plugin binary for the specified target.
|
# Alias to build actual plugin binary for the specified target.
|
||||||
@ -205,10 +205,10 @@ build-wasm32 = "build --target wasm32-unknown-unknown"
|
|||||||
let dist_output_path = format!(
|
let dist_output_path = format!(
|
||||||
"target/{}/release/{}.wasm",
|
"target/{}/release/{}.wasm",
|
||||||
build_target,
|
build_target,
|
||||||
name.replace("-", "_")
|
name.replace('-', "_")
|
||||||
);
|
);
|
||||||
fs::write(
|
fs::write(
|
||||||
&path.join("package.json"),
|
path.join("package.json"),
|
||||||
format!(
|
format!(
|
||||||
r#"{{
|
r#"{{
|
||||||
"name": "{}",
|
"name": "{}",
|
||||||
@ -235,7 +235,7 @@ build-wasm32 = "build --target wasm32-unknown-unknown"
|
|||||||
let src_path = path.join("src");
|
let src_path = path.join("src");
|
||||||
create_dir_all(&src_path)?;
|
create_dir_all(&src_path)?;
|
||||||
fs::write(
|
fs::write(
|
||||||
&src_path.join("lib.rs"),
|
src_path.join("lib.rs"),
|
||||||
r##"use swc_core::ecma::{
|
r##"use swc_core::ecma::{
|
||||||
ast::Program,
|
ast::Program,
|
||||||
transforms::testing::test,
|
transforms::testing::test,
|
17
crates/swc_cli_impl/src/lib.rs
Normal file
17
crates/swc_cli_impl/src/lib.rs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
use clap::Parser;
|
||||||
|
use commands::{Command, CommandRunner, PluginSubcommand, SwcCliOptions};
|
||||||
|
|
||||||
|
mod commands;
|
||||||
|
mod util;
|
||||||
|
|
||||||
|
pub fn run() -> anyhow::Result<()> {
|
||||||
|
let command = SwcCliOptions::parse().command;
|
||||||
|
|
||||||
|
match &command {
|
||||||
|
Command::Plugin(PluginSubcommand::New(options)) => options.execute(),
|
||||||
|
Command::Compile(options) => options.execute(),
|
||||||
|
Command::Minify(options) => options.execute(),
|
||||||
|
Command::Bundle(options) => options.execute(),
|
||||||
|
Command::Lint(options) => options.execute(),
|
||||||
|
}
|
||||||
|
}
|
@ -13,20 +13,22 @@ version = "0.1.5"
|
|||||||
node = ["napi", "napi-derive"]
|
node = ["napi", "napi-derive"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0.75"
|
anyhow = "1.0.75"
|
||||||
base64 = "0.13.0"
|
base64 = "0.13.0"
|
||||||
pathdiff = "0.2.0"
|
pathdiff = "0.2.0"
|
||||||
serde = { version = "1.0.188", features = ["derive"] }
|
serde = { version = "1.0.188", features = ["derive"] }
|
||||||
sourcemap = "6.2"
|
sourcemap = "6.2"
|
||||||
swc_atoms = { version = "0.5.9", path = "../swc_atoms" }
|
swc_atoms = { version = "0.5.9", path = "../swc_atoms" }
|
||||||
swc_common = { version = "0.32.1", path = "../swc_common" }
|
swc_common = { version = "0.32.1", path = "../swc_common", features = [
|
||||||
swc_config = { version = "0.1.7", path = "../swc_config" }
|
"sourcemap",
|
||||||
swc_ecma_ast = { version = "0.109.1", path = "../swc_ecma_ast" }
|
] }
|
||||||
|
swc_config = { version = "0.1.7", path = "../swc_config" }
|
||||||
|
swc_ecma_ast = { version = "0.109.1", path = "../swc_ecma_ast" }
|
||||||
swc_ecma_codegen = { version = "0.145.5", path = "../swc_ecma_codegen" }
|
swc_ecma_codegen = { version = "0.145.5", path = "../swc_ecma_codegen" }
|
||||||
swc_ecma_minifier = { version = "0.187.26", path = "../swc_ecma_minifier" }
|
swc_ecma_minifier = { version = "0.187.26", path = "../swc_ecma_minifier" }
|
||||||
swc_ecma_parser = { version = "0.140.0", path = "../swc_ecma_parser" }
|
swc_ecma_parser = { version = "0.140.0", path = "../swc_ecma_parser" }
|
||||||
swc_ecma_visit = { version = "0.95.1", path = "../swc_ecma_visit" }
|
swc_ecma_visit = { version = "0.95.1", path = "../swc_ecma_visit" }
|
||||||
swc_timer = { version = "0.20.1", path = "../swc_timer" }
|
swc_timer = { version = "0.20.1", path = "../swc_timer" }
|
||||||
|
|
||||||
[dependencies.napi-derive]
|
[dependencies.napi-derive]
|
||||||
default-features = false
|
default-features = false
|
||||||
|
Loading…
Reference in New Issue
Block a user