dwkim 0.0.3 → 0.0.4

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/dist/index.js ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/index.ts
4
+ import chalk from "chalk";
5
+ import boxen from "boxen";
6
+ import fs from "node:fs";
7
+ import path from "node:path";
8
+ var profile = JSON.parse(
9
+ fs.readFileSync(path.join(process.cwd(), "./profile.json"), "utf8")
10
+ );
11
+ var boxenOptions = {
12
+ padding: 1,
13
+ margin: 0,
14
+ borderStyle: "round",
15
+ borderColor: "green",
16
+ fullscreen: (width, height) => [width, height - 10]
17
+ };
18
+ var cardContent = [
19
+ chalk.white.bold(profile.name),
20
+ chalk.white(profile.title),
21
+ chalk.white(profile.bio),
22
+ "",
23
+ chalk.gray.bgWhite("Email: ") + chalk.white(profile.email),
24
+ chalk.gray.bgWhite("GitHub: ") + chalk.white(profile.github),
25
+ chalk.gray.bgWhite("Website: ") + chalk.white(profile.website),
26
+ "",
27
+ chalk.white("Out of box, pay it forward \u{1F44B}")
28
+ ].join("\n");
29
+ console.log(boxen(cardContent, boxenOptions));
@@ -0,0 +1,10 @@
1
+ {
2
+ "id": "cm56dtotk0000rhdwho2wmz7n",
3
+ "name": "김동욱",
4
+ "email": "ollie101@kakao.com",
5
+ "emailVerified": null,
6
+ "title": null,
7
+ "github": null,
8
+ "website": null,
9
+ "bio": null
10
+ }
package/package.json CHANGED
@@ -1,26 +1,24 @@
1
1
  {
2
2
  "name": "dwkim",
3
- "version": "0.0.3",
4
- "description": "",
5
- "main": "index.js",
3
+ "version": "0.0.4",
6
4
  "type": "module",
7
- "bin": "./dist/src/index.js",
8
- "keywords": [],
9
- "author": "",
10
- "license": "ISC",
11
- "dependencies": {
12
- "boxen": "^8.0.1",
13
- "chalk": "^5.4.1",
14
- "ts-node": "^10.9.2"
15
- },
5
+ "bin": "./dist/index.js",
16
6
  "devDependencies": {
17
- "typescript": "5.5.4",
7
+ "@types/node": "^20.11.24",
8
+ "esbuild": "^0.24.2",
9
+ "ts-node": "^10.9.2",
10
+ "typescript": "~5.6.2",
18
11
  "@repo/database": "1.0.0",
19
- "@repo/typescript-config": "0.0.0",
20
- "@repo/eslint-config": "0.0.0"
12
+ "@repo/typescript-config": "0.0.0"
13
+ },
14
+ "dependencies": {
15
+ "boxen": "^8.0.1",
16
+ "chalk": "^5.4.1"
21
17
  },
22
18
  "scripts": {
23
- "dev": "npm run build && node dist/src/index.js",
24
- "build": "tsc"
19
+ "start": "npm run build && node dist/index.js",
20
+ "build": "node script/build.js",
21
+ "build:watch": "node script/build.js --watch",
22
+ "prebuild": "node script/loadProfile.js"
25
23
  }
26
24
  }
package/profile.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "id": "cm56dtotk0000rhdwho2wmz7n",
3
+ "name": "김동욱",
4
+ "email": "ollie101@kakao.com",
5
+ "emailVerified": null,
6
+ "title": null,
7
+ "github": null,
8
+ "website": null,
9
+ "bio": null
10
+ }
@@ -0,0 +1,39 @@
1
+ import * as esbuild from 'esbuild';
2
+ import fs from 'node:fs/promises';
3
+
4
+ const config = {
5
+ entryPoints: ['src/index.ts'],
6
+ bundle: true,
7
+ platform: 'node',
8
+ format: 'esm',
9
+ outfile: 'dist/index.js',
10
+ banner: {
11
+ js: '#!/usr/bin/env node',
12
+ },
13
+ external: ['chalk', 'boxen'],
14
+ };
15
+
16
+ // JSON 파일 복사 함수
17
+ async function copyJsonFiles() {
18
+ try {
19
+ await fs.mkdir('dist', { recursive: true });
20
+ await fs.copyFile('profile.json', 'dist/profile.json');
21
+ console.log('JSON files copied successfully');
22
+ } catch (err) {
23
+ console.error('Error copying JSON files:', err);
24
+ }
25
+ }
26
+
27
+ const args = process.argv.slice(2);
28
+ const watch = args.includes('--watch');
29
+
30
+ if (watch) {
31
+ const ctx = await esbuild.context(config);
32
+ await copyJsonFiles(); // 초기 복사
33
+ await ctx.watch();
34
+ console.log('Watching...');
35
+ } else {
36
+ await esbuild.build(config);
37
+ await copyJsonFiles(); // 빌드 후 복사
38
+ console.log('Built!');
39
+ }
@@ -0,0 +1,10 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { prisma } from '@repo/database';
4
+
5
+ prisma.user.findFirst().then((user) => {
6
+ fs.writeFileSync(
7
+ path.join(process.cwd(), '/src/profile.json'),
8
+ JSON.stringify(user, null, 2)
9
+ );
10
+ });
package/src/index.ts CHANGED
@@ -1,36 +1,31 @@
1
- #!/usr/bin/env node
2
-
3
1
  import chalk from 'chalk';
4
2
  import boxen, { type Options } from 'boxen';
5
- import { prisma } from '@repo/database';
3
+ import fs from 'node:fs';
4
+ import path from 'node:path';
5
+
6
+ const profile = JSON.parse(
7
+ fs.readFileSync(path.join(process.cwd(), './profile.json'), 'utf8')
8
+ );
6
9
 
7
- // 명함 스타일 설정
8
10
  const boxenOptions: Options = {
9
11
  padding: 1,
10
- margin: 1,
12
+ margin: 0,
11
13
  borderStyle: 'round',
12
14
  borderColor: 'green',
15
+ fullscreen: (width, height) => [width, height - 10],
13
16
  };
14
17
 
15
- const main = async () => {
16
- const cardData = await prisma.user.findFirst();
17
- if (!cardData) {
18
- console.error('No card data found');
19
- return;
20
- }
21
-
22
- const cardContent = [
23
- chalk.white.bold(cardData.name),
24
- chalk.white(cardData.title),
25
- chalk.white(cardData.bio),
26
- '',
27
- chalk.gray('Email: ') + chalk.white(cardData.email),
28
- chalk.gray('GitHub: ') + chalk.white(cardData.github),
29
- chalk.gray('Website: ') + chalk.white(cardData.website),
30
- ].join('\n');
31
-
32
- // 명함 출력
33
- console.log(boxen(cardContent, boxenOptions));
34
- };
18
+ const cardContent = [
19
+ chalk.white.bold(profile.name),
20
+ chalk.white(profile.title),
21
+ chalk.white(profile.bio),
22
+ '',
23
+ chalk.gray.bgWhite('Email: ') + chalk.white(profile.email),
24
+ chalk.gray.bgWhite('GitHub: ') + chalk.white(profile.github),
25
+ chalk.gray.bgWhite('Website: ') + chalk.white(profile.website),
26
+ '',
27
+ chalk.white('Out of box, pay it forward 👋'),
28
+ ].join('\n');
35
29
 
36
- main();
30
+ // 명함 출력
31
+ console.log(boxen(cardContent, boxenOptions));
@@ -0,0 +1,10 @@
1
+ {
2
+ "id": "cm56dtotk0000rhdwho2wmz7n",
3
+ "name": "김동욱",
4
+ "email": "ollie101@kakao.com",
5
+ "emailVerified": null,
6
+ "title": null,
7
+ "github": null,
8
+ "website": null,
9
+ "bio": null
10
+ }
package/tsconfig.json CHANGED
@@ -1,16 +1,14 @@
1
1
  {
2
2
  "extends": "@repo/typescript-config/base.json",
3
3
  "compilerOptions": {
4
- "target": "es2017",
5
- "module": "ES2015",
6
- "outDir": "./dist",
7
- "rootDir": "./",
8
- "strict": true,
4
+ "target": "ES2022",
5
+ "module": "NodeNext",
6
+ "moduleResolution": "NodeNext",
7
+ "resolveJsonModule": true,
9
8
  "esModuleInterop": true,
10
- "skipLibCheck": true,
11
- "forceConsistentCasingInFileNames": true,
12
- "incremental": false
9
+ "outDir": "./dist",
10
+ "types": ["node"]
13
11
  },
14
- "include": ["**/*.ts"],
12
+ "include": ["**/*.ts", "script/loadProfile.js", "src/index.ts"],
15
13
  "exclude": ["node_modules", "dist"]
16
14
  }
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":""}
package/dist/src/index.js DELETED
@@ -1,30 +0,0 @@
1
- #!/usr/bin/env node
2
- import chalk from 'chalk';
3
- import boxen from 'boxen';
4
- import { prisma } from '@repo/database';
5
- // 명함 스타일 설정
6
- const boxenOptions = {
7
- padding: 1,
8
- margin: 1,
9
- borderStyle: 'round',
10
- borderColor: 'green',
11
- };
12
- const main = async () => {
13
- const cardData = await prisma.user.findFirst();
14
- if (!cardData) {
15
- console.error('No card data found');
16
- return;
17
- }
18
- const cardContent = [
19
- chalk.white.bold(cardData.name),
20
- chalk.white(cardData.title),
21
- chalk.white(cardData.bio),
22
- '',
23
- chalk.gray('Email: ') + chalk.white(cardData.email),
24
- chalk.gray('GitHub: ') + chalk.white(cardData.github),
25
- chalk.gray('Website: ') + chalk.white(cardData.website),
26
- ].join('\n');
27
- // 명함 출력
28
- console.log(boxen(cardContent, boxenOptions));
29
- };
30
- main();