Skip to content

Commit 127a2be

Browse files
index.tsx (#13)
* fix index.tsx * pretty, always
1 parent a67df6d commit 127a2be

File tree

4 files changed

+45
-17
lines changed

4 files changed

+45
-17
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# pix31
22

3+
## 1.0.11
4+
5+
### Patch Changes
6+
7+
- React `index.ts` file should have `.tsx` extension
8+
- Polish `info` logs on successful init
9+
310
## 1.0.10
411

512
### Patch Changes

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"publish": "npm publish --access public"
1717
},
1818
"name": "pix31",
19-
"version": "1.0.10",
19+
"version": "1.0.11",
2020
"private": false,
2121
"main": "dist/index.js",
2222
"module": "dist/index.mjs",

src/lib/utils.test.ts

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ describe("ensureIndexFile()", () => {
466466
recursive: true,
467467
});
468468
expect(fs.writeFileSync).toHaveBeenCalledWith(
469-
path.join(process.cwd(), "src/icons/index.ts"),
469+
path.join(process.cwd(), "src/icons/index.tsx"),
470470
expect.stringContaining("react-native-svg")
471471
);
472472
});
@@ -482,7 +482,7 @@ describe("ensureIndexFile()", () => {
482482
ensureIndexFile(config);
483483

484484
expect(fs.writeFileSync).toHaveBeenCalledWith(
485-
path.join(process.cwd(), "src/icons/index.ts"),
485+
path.join(process.cwd(), "src/icons/index.tsx"),
486486
expect.not.stringContaining("react-native-svg")
487487
);
488488
});
@@ -527,7 +527,7 @@ describe("appendIconExport()", () => {
527527
appendIconExport(nativeConfig, "home");
528528

529529
expect(fs.appendFileSync).toHaveBeenCalledWith(
530-
path.join(process.cwd(), "src/icons/index.ts"),
530+
path.join(process.cwd(), "src/icons/index.tsx"),
531531
'\nexport * from "./home";\n'
532532
);
533533
});
@@ -538,7 +538,7 @@ describe("appendIconExport()", () => {
538538
appendIconExport(reactConfig, "home");
539539

540540
expect(fs.appendFileSync).toHaveBeenCalledWith(
541-
path.join(process.cwd(), "src/icons/index.ts"),
541+
path.join(process.cwd(), "src/icons/index.tsx"),
542542
'\nexport { HomeIcon } from "./home";\n'
543543
);
544544
});
@@ -667,15 +667,28 @@ describe("printInitSuccess()", () => {
667667
consoleLogSpy.mockRestore();
668668
});
669669

670-
it("Prints formatted success message", () => {
670+
it("Prints formatted success message with chalk colors", () => {
671671
printInitSuccess();
672672

673-
expect(consoleLogSpy).toHaveBeenCalledWith("Commands you can run:");
674-
expect(consoleLogSpy).toHaveBeenCalledWith(
675-
` npx ${LIB_NAME} browse Search pixelarticons website`
673+
expect(consoleLogSpy).toHaveBeenCalledTimes(5);
674+
expect(consoleLogSpy).toHaveBeenNthCalledWith(
675+
1,
676+
expect.stringContaining("--------------------------------")
676677
);
677-
expect(consoleLogSpy).toHaveBeenCalledWith(
678-
` npx ${LIB_NAME} add [icon-1] [icon-2] ... Add icons to your project`
678+
expect(consoleLogSpy).toHaveBeenNthCalledWith(2, expect.any(String), "Commands you can run:");
679+
expect(consoleLogSpy).toHaveBeenNthCalledWith(
680+
3,
681+
expect.any(String),
682+
`npx ${LIB_NAME} browse Search pixelarticons website`
683+
);
684+
expect(consoleLogSpy).toHaveBeenNthCalledWith(
685+
4,
686+
expect.any(String),
687+
`npx ${LIB_NAME} add [icon-1] [icon-2] ... Add icons to your project`
688+
);
689+
expect(consoleLogSpy).toHaveBeenNthCalledWith(
690+
5,
691+
expect.stringContaining("--------------------------------")
679692
);
680693
});
681694
});

src/lib/utils.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ export function readConfig(): JsonConfig | null {
174174
}
175175

176176
export function ensureIndexFile(config: JsonConfig): void {
177-
const indexPath = path.join(process.cwd(), config.outputPath, "index.ts");
177+
const indexPath = path.join(process.cwd(), config.outputPath, "index.tsx");
178178

179179
if (!fs.existsSync(path.dirname(indexPath))) {
180180
fs.mkdirSync(path.dirname(indexPath), { recursive: true });
@@ -189,7 +189,7 @@ export function ensureIndexFile(config: JsonConfig): void {
189189
}
190190

191191
export function appendIconExport(config: JsonConfig, iconName: string): void {
192-
const indexPath = path.join(process.cwd(), config.outputPath, "index.ts");
192+
const indexPath = path.join(process.cwd(), config.outputPath, "index.tsx");
193193
const existingContent = fs.readFileSync(indexPath, "utf-8");
194194
const exportLine =
195195
config.platform === "native"
@@ -311,7 +311,7 @@ export async function generateReactIcons(): Promise<GenerationStats> {
311311

312312
export async function generateIndexFile(): Promise<void> {
313313
const reactIconsDir = path.resolve("react-icons");
314-
const indexPath = path.join(reactIconsDir, "index.ts");
314+
const indexPath = path.join(reactIconsDir, "index.tsx");
315315

316316
let indexContent = `export { Pix31Icon, Pix31IconProps } from "../lib/pix31-icon";\n\n`;
317317

@@ -340,7 +340,15 @@ export function configureAddCommand(program: Command): void {
340340
}
341341

342342
export function printInitSuccess(): void {
343-
console.log("Commands you can run:");
344-
console.log(` npx ${LIB_NAME} browse Search pixelarticons website`);
345-
console.log(` npx ${LIB_NAME} add [icon-1] [icon-2] ... Add icons to your project`);
343+
console.log(chalk.gray("--------------------------------"));
344+
console.log(chalk.white("ℹ"), "Commands you can run:");
345+
console.log(
346+
chalk.blue("+"),
347+
`npx ${LIB_NAME} browse Search pixelarticons website`
348+
);
349+
console.log(
350+
chalk.green("+"),
351+
`npx ${LIB_NAME} add [icon-1] [icon-2] ... Add icons to your project`
352+
);
353+
console.log(chalk.gray("--------------------------------"));
346354
}

0 commit comments

Comments
 (0)