noshift.js 0.2.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README-ja.md CHANGED
@@ -1,10 +1,21 @@
1
- # noshift.js
1
+ [![npm](https://img.shields.io/npm/v/noshift.js)](https://www.npmjs.com/package/noshift.js) [![license](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
2
+
3
+ # NoShift.js
4
+
5
+ <div align="center">
6
+ <img src="https://raw.githubusercontent.com/otoneko1102/NoShift.js/refs/heads/main/icon.png" alt="noshift.js" width="128" height="128">
7
+ </div>
8
+
9
+ <div align="center">
10
+
11
+ [English](./README.md) | **日本語**
12
+
13
+ </div>
2
14
 
3
15
  > Shift キーを押さずに JavaScript を書ける Joke 言語
4
16
 
5
- [![npm](https://img.shields.io/npm/v/noshift.js)](https://www.npmjs.com/package/noshift.js)
6
- [![license](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
7
- [![en](https://img.shields.io/badge/lang-English_version-blue)](README.md)
17
+ 記号 (`!`, `"`, `(`, `)`, `{`, `}` …) を入力するときに Shift を押すのが面倒なので、Shift を押さずに JavaScript が書けるようにした Joke 言語です。
18
+ `^` プレフィックスのシーケンスで Shift が必要な記号を表現し、`.nsjs` ファイルは `nsc` CLI を使って JavaScript にコンパイルされます。
8
19
 
9
20
  ---
10
21
 
@@ -19,11 +30,11 @@ npm install -g noshift.js@latest
19
30
  ## はじめに
20
31
 
21
32
  ```bash
22
- # インタラクティブなプロジェクトスキャフォールド
23
- nsc create
33
+ # 新しいプロジェクトを作成
34
+ nsc create my-project
24
35
 
25
36
  # または、現在のディレクトリに nsjsconfig.json だけを作成
26
- nsc --init
37
+ nsc init
27
38
  ```
28
39
 
29
40
  ---
@@ -32,37 +43,41 @@ nsc --init
32
43
 
33
44
  `nsc` は TypeScript の `tsc` に似た使い心地を目指しています。
34
45
 
35
- | コマンド | 説明 |
36
- |---|---|
37
- | `nsc` | `nsjsconfig.json` を使って `.nsjs` → `.js` にコンパイル |
38
- | `nsc -w` / `nsc --watch` | 変更を監視して自動的に再コンパイル |
39
- | `nsc --init` | 現在のディレクトリに `nsjsconfig.json` を作成 |
40
- | `nsc --clean` | 出力ディレクトリ (`outDir`) を削除 |
41
- | `nsc run <file>` | `.nsjs` ファイルを直接実行 |
42
- | `nsc create [name]` | インタラクティブに新しいプロジェクトを作成 |
43
- | `nsc -V` | バージョンを表示 |
44
- | `nsc -h` | ヘルプを表示 |
46
+ | コマンド | エイリアス | 説明 |
47
+ |---|---|---|
48
+ | `nsc` | | `nsjsconfig.json` を使って `.nsjs` → `.js` にコンパイル |
49
+ | `nsc watch` | `nsc -w` `nsc --watch` | 変更を監視して自動的に再コンパイル |
50
+ | `nsc init` | `nsc --init` | 現在のディレクトリに `nsjsconfig.json` を作成 |
51
+ | `nsc clean` | `nsc --clean` | 出力ディレクトリ (`outdir`) を削除 |
52
+ | `nsc run <file>` | `nsc -r <file>` `nsc --run <file>` | `.nsjs` ファイルを直接実行 |
53
+ | `nsc create [name]` | `nsc --create [name]` | 新しいプロジェクトを作成(`--no-prettier` で Prettier スキップ) |
54
+ | `nsc version` | `nsc -v` `nsc --version` | バージョンを表示 |
55
+ | `nsc help` | `nsc -h` `nsc --help` | ヘルプを表示 |
45
56
 
46
57
  ---
47
58
 
48
59
  ## nsjsconfig.json
49
60
 
50
61
  プロジェクトルートに `nsjsconfig.json` を置くとコンパイル設定を行えます。
51
- `nsc --init` または `nsc create` で自動生成されます。
62
+ `nsc init` または `nsc create` で自動生成されます。
52
63
 
53
64
  ```json
54
65
  {
55
- "compilerOptions": {
56
- "rootDir": "src",
57
- "outDir": "build"
66
+ "compileroptions": {
67
+ "rootdir": "src",
68
+ "outdir": "dist",
69
+ "warnuppercase": true,
70
+ "capitalizeinstrings": true
58
71
  }
59
72
  }
60
73
  ```
61
74
 
62
75
  | オプション | デフォルト | 説明 |
63
76
  |---|---|---|
64
- | `compilerOptions.rootDir` | `"src"` | ソースディレクトリ |
65
- | `compilerOptions.outDir` | `"build"` | 出力ディレクトリ |
77
+ | `compileroptions.rootdir` | `"src"` | ソースディレクトリ |
78
+ | `compileroptions.outdir` | `"dist"` | 出力ディレクトリ |
79
+ | `compileroptions.warnuppercase` | `true` | ソースコード内の大文字を警告 |
80
+ | `compileroptions.capitalizeinstrings` | `true` | 文字列リテラル内で `^3` 大文字化修飾子を有効にする |
66
81
 
67
82
  ---
68
83
 
@@ -76,14 +91,14 @@ nsc --init
76
91
  |:-------:|:--:|---|:-------:|:--:|
77
92
  | `^1` | `!` | | `^^` | `~` |
78
93
  | `^2` | `"` | | `^\` | `\|` |
79
- | `^4` | `$` | | `^@` | `` ` `` |
80
- | `^5` | `%` | | `^[` | `{` |
81
- | `^6` | `&` | | `^]` | `}` |
82
- | `^7` | `'` | | `^;` | `+` |
83
- | `^8` | `(` | | `^:` | `*` |
84
- | `^9` | `)` | | `^,` | `<` |
85
- | `^-` | `=` | | `^.` | `>` |
86
- | | | | `^/` | `?` |
94
+ | `^3x` | `X`(大文字化) | | `^@` | `` ` `` |
95
+ | `^4` | `$` | | `^[` | `{` |
96
+ | `^5` | `%` | | `^]` | `}` |
97
+ | `^6` | `&` | | `^;` | `+` |
98
+ | `^7` | `'` | | `^:` | `*` |
99
+ | `^8` | `(` | | `^,` | `<` |
100
+ | `^9` | `)` | | `^.` | `>` |
101
+ | `^-` | `=` | | `^/` | `?` |
87
102
 
88
103
  テンプレート式: `^4^[` → `${`
89
104
 
@@ -101,6 +116,44 @@ console.log^8^2Hello, World!^2^9;
101
116
  console.log("Hello, World!");
102
117
  ```
103
118
 
119
+ ### 大文字化修飾子
120
+
121
+ `^3` は次の文字を大文字にします:
122
+
123
+ ```nsjs
124
+ class ^3animal ^[
125
+ ^]
126
+ ```
127
+
128
+ ```js
129
+ class Animal {
130
+ }
131
+ ```
132
+
133
+ ### コメント
134
+
135
+ ```nsjs
136
+ // 行コメント
137
+
138
+ /^: ブロックコメント ^:/
139
+
140
+ /^:
141
+ 複数行の
142
+ ブロックコメント
143
+ ^:/
144
+ ```
145
+
146
+ ```js
147
+ // 行コメント
148
+
149
+ /* ブロックコメント */
150
+
151
+ /*
152
+ 複数行の
153
+ ブロックコメント
154
+ */
155
+ ```
156
+
104
157
  ### 変数とアロー関数
105
158
 
106
159
  ```nsjs
@@ -165,7 +218,7 @@ const arr = [1, 2, 3];
165
218
  ### クラス
166
219
 
167
220
  ```nsjs
168
- class Animal ^[
221
+ class ^3animal ^[
169
222
  constructor^8name^9 ^[
170
223
  this.name ^- name;
171
224
  ^]
@@ -175,7 +228,7 @@ class Animal ^[
175
228
  ^]
176
229
  ^]
177
230
 
178
- const dog ^- new Animal^8^2Dog^2^9;
231
+ const dog ^- new ^3animal^8^2Dog^2^9;
179
232
  dog.speak^8^9;
180
233
  ```
181
234
 
package/README.md CHANGED
@@ -1,10 +1,22 @@
1
- # noshift.js
1
+ [![npm](https://img.shields.io/npm/v/noshift.js)](https://www.npmjs.com/package/noshift.js) [![license](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
2
+
3
+ # NoShift.js
4
+
5
+ <div align="center">
6
+ <img src="https://raw.githubusercontent.com/otoneko1102/NoShift.js/refs/heads/main/icon.png" alt="noshift.js" width="128" height="128">
7
+ </div>
8
+
9
+ <div align="center">
10
+
11
+ **English** | [日本語](./README-ja.md)
12
+
13
+ </div>
2
14
 
3
15
  > A joke language that lets you write JavaScript without pressing the Shift key.
4
16
 
5
- [![npm](https://img.shields.io/npm/v/noshift.js)](https://www.npmjs.com/package/noshift.js)
6
- [![license](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
7
- [![ja](https://img.shields.io/badge/lang-日本語_バージョン-red)](README-ja.md)
17
+ Typing shifted symbols (`!`, `"`, `(`, `)`, `{`, `}` …) is tiring.
18
+ **NoShift.js** replaces every shift-required symbol with a `^`-prefixed sequence, so you can write JavaScript using only unshifted keys.
19
+ `.nsjs` files compile directly to plain JavaScript via the `nsc` CLI.
8
20
 
9
21
  ---
10
22
 
@@ -19,11 +31,11 @@ npm install -g noshift.js@latest
19
31
  ## Getting Started
20
32
 
21
33
  ```bash
22
- # Interactive full project scaffold
23
- nsc create
34
+ # Create a new project
35
+ nsc create my-project
24
36
 
25
37
  # Or initialize only a nsjsconfig.json in the current directory
26
- nsc --init
38
+ nsc init
27
39
  ```
28
40
 
29
41
  ---
@@ -32,37 +44,41 @@ nsc --init
32
44
 
33
45
  `nsc` is designed to feel like TypeScript's `tsc`.
34
46
 
35
- | Command | Description |
36
- |---|---|
37
- | `nsc` | Compile `.nsjs` → `.js` using `nsjsconfig.json` |
38
- | `nsc -w` / `nsc --watch` | Watch for changes and recompile automatically |
39
- | `nsc --init` | Create `nsjsconfig.json` in the current directory |
40
- | `nsc --clean` | Delete the output directory (`outDir`) |
41
- | `nsc run <file>` | Run a `.nsjs` file directly |
42
- | `nsc create [name]` | Scaffold a new project interactively |
43
- | `nsc -V` | Show version |
44
- | `nsc -h` | Show help |
47
+ | Command | Alias | Description |
48
+ |---|---|---|
49
+ | `nsc` | | Compile `.nsjs` → `.js` using `nsjsconfig.json` |
50
+ | `nsc watch` | `nsc -w` `nsc --watch` | Watch for changes and recompile automatically |
51
+ | `nsc init` | `nsc --init` | Create `nsjsconfig.json` in the current directory |
52
+ | `nsc clean` | `nsc --clean` | Delete the output directory (`outdir`) |
53
+ | `nsc run <file>` | `nsc -r <file>` `nsc --run <file>` | Run a `.nsjs` file directly |
54
+ | `nsc create [name]` | `nsc --create [name]` | Scaffold a new project (`--no-prettier` to skip Prettier) |
55
+ | `nsc version` | `nsc -v` `nsc --version` | Show version |
56
+ | `nsc help` | `nsc -h` `nsc --help` | Show help |
45
57
 
46
58
  ---
47
59
 
48
60
  ## nsjsconfig.json
49
61
 
50
62
  Place a `nsjsconfig.json` at the project root to configure compilation.
51
- Generated automatically by `nsc --init` or `nsc create`.
63
+ Generated automatically by `nsc init` or `nsc create`.
52
64
 
53
65
  ```json
54
66
  {
55
- "compilerOptions": {
56
- "rootDir": "src",
57
- "outDir": "build"
67
+ "compileroptions": {
68
+ "rootdir": "src",
69
+ "outdir": "dist",
70
+ "warnuppercase": true,
71
+ "capitalizeinstrings": true
58
72
  }
59
73
  }
60
74
  ```
61
75
 
62
76
  | Option | Default | Description |
63
77
  |---|---|---|
64
- | `compilerOptions.rootDir` | `"src"` | Source directory |
65
- | `compilerOptions.outDir` | `"build"` | Output directory |
78
+ | `compileroptions.rootdir` | `"src"` | Source directory |
79
+ | `compileroptions.outdir` | `"dist"` | Output directory |
80
+ | `compileroptions.warnuppercase` | `true` | Warn about uppercase characters in source code |
81
+ | `compileroptions.capitalizeinstrings` | `true` | Enable `^3` capitalize modifier inside string literals |
66
82
 
67
83
  ---
68
84
 
@@ -76,14 +92,14 @@ Generated automatically by `nsc --init` or `nsc create`.
76
92
  |:-------:|:--:|---|:-------:|:--:|
77
93
  | `^1` | `!` | | `^^` | `~` |
78
94
  | `^2` | `"` | | `^\` | `\|` |
79
- | `^4` | `$` | | `^@` | `` ` `` |
80
- | `^5` | `%` | | `^[` | `{` |
81
- | `^6` | `&` | | `^]` | `}` |
82
- | `^7` | `'` | | `^;` | `+` |
83
- | `^8` | `(` | | `^:` | `*` |
84
- | `^9` | `)` | | `^,` | `<` |
85
- | `^-` | `=` | | `^.` | `>` |
86
- | | | | `^/` | `?` |
95
+ | `^3x` | `X` (capitalize) | | `^@` | `` ` `` |
96
+ | `^4` | `$` | | `^[` | `{` |
97
+ | `^5` | `%` | | `^]` | `}` |
98
+ | `^6` | `&` | | `^;` | `+` |
99
+ | `^7` | `'` | | `^:` | `*` |
100
+ | `^8` | `(` | | `^,` | `<` |
101
+ | `^9` | `)` | | `^.` | `>` |
102
+ | `^-` | `=` | | `^/` | `?` |
87
103
 
88
104
  Template expression: `^4^[` → `${`
89
105
 
@@ -101,6 +117,44 @@ console.log^8^2Hello, World!^2^9;
101
117
  console.log("Hello, World!");
102
118
  ```
103
119
 
120
+ ### Capitalize Modifier
121
+
122
+ `^3` capitalizes the next character:
123
+
124
+ ```nsjs
125
+ class ^3animal ^[
126
+ ^]
127
+ ```
128
+
129
+ ```js
130
+ class Animal {
131
+ }
132
+ ```
133
+
134
+ ### Comments
135
+
136
+ ```nsjs
137
+ // line comment
138
+
139
+ /^: block comment ^:/
140
+
141
+ /^:
142
+ multi-line
143
+ block comment
144
+ ^:/
145
+ ```
146
+
147
+ ```js
148
+ // line comment
149
+
150
+ /* block comment */
151
+
152
+ /*
153
+ multi-line
154
+ block comment
155
+ */
156
+ ```
157
+
104
158
  ### Variables & Arrow Functions
105
159
 
106
160
  ```nsjs
@@ -165,7 +219,7 @@ const arr = [1, 2, 3];
165
219
  ### Classes
166
220
 
167
221
  ```nsjs
168
- class Animal ^[
222
+ class ^3animal ^[
169
223
  constructor^8name^9 ^[
170
224
  this.name ^- name;
171
225
  ^]
@@ -175,7 +229,7 @@ class Animal ^[
175
229
  ^]
176
230
  ^]
177
231
 
178
- const dog ^- new Animal^8^2Dog^2^9;
232
+ const dog ^- new ^3animal^8^2Dog^2^9;
179
233
  dog.speak^8^9;
180
234
  ```
181
235
 
package/bin/cli.js CHANGED
@@ -10,32 +10,52 @@ const pkg = JSON.parse(
10
10
  readFileSync(path.join(__dirname, "../package.json"), "utf-8"),
11
11
  );
12
12
 
13
+ const DOCS_URL = "https://noshift.js.org/";
14
+
13
15
  const program = new Command();
14
16
 
15
- // nsc [options] ← デフォルト動作: compile
16
17
  program
17
18
  .name("nsc")
18
19
  .description("NoShift.js compiler")
19
- .version(pkg.version, '-v, --version', 'output the version number')
20
+ .version(pkg.version, "-v, --version", "output the version number")
20
21
  .option("-w, --watch", "Watch for file changes and recompile")
21
22
  .option("--init", "Create a nsjsconfig.json in the current directory")
22
- .option("--clean", "Delete the output directory (outDir)")
23
+ .option("--clean", "Delete the output directory (outdir)")
24
+ .option("-r, --run <file>", "Run a .nsjs file directly")
25
+ .option("--create [name]", "Scaffold a new NoShift.js project")
26
+ .addHelpText("after", `\nDocumentation: ${DOCS_URL}`)
23
27
  .action(async (options) => {
24
- if (options.init) {
28
+ if (options.watch) {
29
+ const { default: dev } = await import("../commands/dev.js");
30
+ await dev();
31
+ } else if (options.init) {
25
32
  const { default: init } = await import("../commands/init.js");
26
33
  await init();
27
34
  } else if (options.clean) {
28
35
  const { default: clean } = await import("../commands/clean.js");
29
36
  await clean();
30
- } else if (options.watch) {
31
- const { default: dev } = await import("../commands/dev.js");
32
- await dev();
37
+ } else if (options.run) {
38
+ const { default: run } = await import("../commands/run.js");
39
+ await run(options.run);
40
+ } else if (options.create !== undefined) {
41
+ const { default: create } = await import("../commands/create.js");
42
+ await create(options.create || undefined);
33
43
  } else {
34
44
  const { default: compile } = await import("../commands/compile.js");
35
45
  await compile();
36
46
  }
37
47
  });
38
48
 
49
+ // nsc watch
50
+ program
51
+ .command("watch")
52
+ .alias("w")
53
+ .description("Watch for file changes and recompile")
54
+ .action(async () => {
55
+ const { default: dev } = await import("../commands/dev.js");
56
+ await dev();
57
+ });
58
+
39
59
  // nsc run <file>
40
60
  program
41
61
  .command("run <file>")
@@ -45,13 +65,49 @@ program
45
65
  await run(file);
46
66
  });
47
67
 
48
- // nsc create [name] ← 対話式プロジェクト作成
68
+ // nsc create [name]
49
69
  program
50
70
  .command("create [name]")
51
- .description("Scaffold a new NoShift.js project interactively")
52
- .action(async (name) => {
71
+ .description("Scaffold a new NoShift.js project")
72
+ .option("--prettier", "Include Prettier (default)")
73
+ .option("--no-prettier", "Skip Prettier setup")
74
+ .action(async (name, options) => {
53
75
  const { default: create } = await import("../commands/create.js");
54
- await create(name);
76
+ await create(name, options);
77
+ });
78
+
79
+ // nsc init
80
+ program
81
+ .command("init")
82
+ .description("Create a nsjsconfig.json in the current directory")
83
+ .action(async () => {
84
+ const { default: init } = await import("../commands/init.js");
85
+ await init();
86
+ });
87
+
88
+ // nsc clean
89
+ program
90
+ .command("clean")
91
+ .description("Delete the output directory (outdir)")
92
+ .action(async () => {
93
+ const { default: clean } = await import("../commands/clean.js");
94
+ await clean();
95
+ });
96
+
97
+ // nsc version
98
+ program
99
+ .command("version")
100
+ .description("Display the current version")
101
+ .action(() => {
102
+ console.log(pkg.version);
103
+ });
104
+
105
+ // nsc help
106
+ program
107
+ .command("help")
108
+ .description("Show help information")
109
+ .action(() => {
110
+ program.outputHelp();
55
111
  });
56
112
 
57
113
  program.parse();
package/commands/clean.js CHANGED
@@ -1,29 +1,33 @@
1
1
  import { rm, access } from "fs/promises";
2
2
  import path from "path";
3
3
  import { loadConfig } from "../src/config.js";
4
+ import { handleSigint } from "../src/signal-handler.js";
5
+ import * as logger from "../src/logger.js";
4
6
 
5
7
  export default async function clean() {
8
+ handleSigint();
9
+
6
10
  const cwd = process.cwd();
7
11
 
8
12
  let config;
9
13
  try {
10
14
  config = await loadConfig(cwd);
11
15
  } catch (e) {
12
- console.error(`error NS0: ${e.message}`);
16
+ logger.errorCode("NS0", e.message);
13
17
  process.exit(1);
14
18
  }
15
19
 
16
- const outDir = path.resolve(cwd, config.compilerOptions.outDir);
20
+ const outDir = path.resolve(cwd, config.compileroptions.outdir);
17
21
 
18
22
  try {
19
23
  await access(outDir);
20
24
  } catch {
21
- console.log(
22
- `Nothing to clean ('${config.compilerOptions.outDir}' does not exist).`,
25
+ logger.info(
26
+ `Nothing to clean (${logger.highlight(config.compileroptions.outdir)} does not exist).`,
23
27
  );
24
28
  return;
25
29
  }
26
30
 
27
31
  await rm(outDir, { recursive: true, force: true });
28
- console.log(`Deleted '${config.compilerOptions.outDir}'.`);
32
+ logger.success(`Deleted ${logger.highlight(config.compileroptions.outdir)}`);
29
33
  }
@@ -1,7 +1,9 @@
1
1
  import { promises as fs } from "fs";
2
2
  import path from "path";
3
- import convert from "../src/convert.js";
3
+ import convert, { checkUppercaseWarnings } from "../src/convert.js";
4
4
  import { loadConfig } from "../src/config.js";
5
+ import { handleSigint } from "../src/signal-handler.js";
6
+ import * as logger from "../src/logger.js";
5
7
 
6
8
  async function findNsjsFiles(dir) {
7
9
  let entries;
@@ -25,30 +27,33 @@ async function findNsjsFiles(dir) {
25
27
  }
26
28
 
27
29
  export default async function compile() {
30
+ handleSigint();
31
+
28
32
  const cwd = process.cwd();
29
33
 
30
34
  let config;
31
35
  try {
32
36
  config = await loadConfig(cwd);
33
37
  } catch (e) {
34
- console.error(`error TS0: ${e.message}`);
38
+ logger.errorCode("NS0", e.message);
35
39
  process.exit(1);
36
40
  }
37
41
 
38
- const rootDir = path.resolve(cwd, config.compilerOptions.rootDir);
39
- const outDir = path.resolve(cwd, config.compilerOptions.outDir);
42
+ const rootDir = path.resolve(cwd, config.compileroptions.rootdir);
43
+ const outDir = path.resolve(cwd, config.compileroptions.outdir);
40
44
 
41
45
  const files = await findNsjsFiles(rootDir);
42
46
 
43
47
  if (files === null) {
44
- console.error(
45
- `error NS0: rootDir '${config.compilerOptions.rootDir}' not found.`,
48
+ logger.errorCode(
49
+ "NS0",
50
+ `rootdir '${config.compileroptions.rootdir}' not found.`,
46
51
  );
47
52
  process.exit(1);
48
53
  }
49
54
 
50
55
  if (files.length === 0) {
51
- console.log("No .nsjs files found.");
56
+ logger.info("No .nsjs files found.");
52
57
  return;
53
58
  }
54
59
 
@@ -56,6 +61,11 @@ export default async function compile() {
56
61
 
57
62
  let compiled = 0;
58
63
  let errors = 0;
64
+ let totalWarnings = 0;
65
+ const warnUppercase = config.compileroptions.warnuppercase !== false;
66
+ const convertOptions = {
67
+ capitalizeInStrings: config.compileroptions.capitalizeinstrings !== false,
68
+ };
59
69
 
60
70
  for (const file of files) {
61
71
  const relative = path.relative(rootDir, file);
@@ -63,27 +73,42 @@ export default async function compile() {
63
73
 
64
74
  try {
65
75
  const code = await fs.readFile(file, "utf-8");
66
- const js = convert(code);
76
+
77
+ // 大文字警告チェック
78
+ if (warnUppercase) {
79
+ const warnings = checkUppercaseWarnings(code);
80
+ for (const w of warnings) {
81
+ logger.warn(
82
+ `${relative.replace(/\\/g, "/")}:${w.line}:${w.column} - ${w.message}`,
83
+ );
84
+ totalWarnings++;
85
+ }
86
+ }
87
+
88
+ const js = convert(code, convertOptions);
67
89
 
68
90
  await fs.mkdir(path.dirname(destPath), { recursive: true });
69
91
  await fs.writeFile(destPath, js, "utf-8");
70
92
 
71
- console.log(
93
+ logger.dim(
72
94
  ` ${relative.replace(/\\/g, "/")} → ${path.relative(cwd, destPath).replace(/\\/g, "/")}`,
73
95
  );
74
96
  compiled++;
75
97
  } catch (e) {
76
- console.error(
77
- ` error NS1: ${relative.replace(/\\/g, "/")}: ${e.message}`,
78
- );
98
+ logger.errorCode("NS1", `${relative.replace(/\\/g, "/")}: ${e.message}`);
79
99
  errors++;
80
100
  }
81
101
  }
82
102
 
103
+ console.log("");
83
104
  if (errors > 0) {
84
- console.error(`\nFound ${errors} error(s). Compiled ${compiled} file(s).`);
105
+ logger.error(`Found ${errors} error(s). Compiled ${compiled} file(s).`);
85
106
  process.exit(1);
86
107
  } else {
87
- console.log(`\nSuccessfully compiled ${compiled} file(s).`);
108
+ let msg = `Compiled ${compiled} file(s).`;
109
+ if (totalWarnings > 0) {
110
+ msg += ` (${totalWarnings} warning(s))`;
111
+ }
112
+ logger.success(msg);
88
113
  }
89
114
  }