-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
117 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Taskl Publish | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# 1. 저장소 체크아웃 | ||
- name: Check out the repository | ||
uses: actions/checkout@v3 | ||
|
||
# 2. Node.js 설치 (원하는 Node 버전을 설정 가능) | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '18' | ||
cache: 'npm' | ||
|
||
# 3. npm 인증 설정 (NPM_TOKEN을 이용해 자동 로그인) | ||
- name: Authenticate to npm | ||
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc | ||
|
||
# 4. npm 설치 | ||
- name: Install dependencies | ||
run: npm install | ||
|
||
# 5. npm publish 실행 | ||
- name: Publish package | ||
run: npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
export declare const ANSI_COLORS: { | ||
cyan: string; | ||
gray: string; | ||
green: string; | ||
red: string; | ||
blue: string; | ||
yellow: string; | ||
white: string; | ||
reset: string; | ||
}; | ||
export interface Task { | ||
text: string; | ||
run: () => Promise<void>; | ||
} | ||
export interface TasklOptions { | ||
tasks: Task[]; | ||
startMessage: string; | ||
successMessage: string; | ||
failedMessage: string; | ||
} | ||
export declare class Taskl { | ||
private options; | ||
constructor(options: TasklOptions); | ||
runTasks(): Promise<void>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,49 @@ | ||
import ora from 'ora'; | ||
export const ANSI_COLORS = { | ||
cyan: '\x1b[36m', | ||
gray: '\x1b[90m', | ||
green: '\x1b[32m', | ||
red: '\x1b[31m', | ||
blue: '\x1b[34m', | ||
yellow: '\x1b[33m', | ||
white: '\x1b[37m', | ||
reset: '\x1b[0m' | ||
cyan: '\x1b[36m', | ||
gray: '\x1b[90m', | ||
green: '\x1b[32m', | ||
red: '\x1b[31m', | ||
blue: '\x1b[34m', | ||
yellow: '\x1b[33m', | ||
white: '\x1b[37m', | ||
reset: '\x1b[0m' | ||
}; | ||
export class Taskl { | ||
constructor(options) { | ||
this.options = options; | ||
} | ||
async runTasks() { | ||
console.log(); | ||
console.log(`${ANSI_COLORS.cyan}${this.options.startMessage}${ANSI_COLORS.reset}`); | ||
const startTime = Date.now(); | ||
const totalTasks = this.options.tasks.length; | ||
let allTasksSucceeded = true; | ||
for (let i = 0; i < totalTasks; i++) { | ||
const task = this.options.tasks[i]; | ||
const progressText = `[${i + 1}/${totalTasks}]`; | ||
const spinner = ora({ | ||
text: `${ANSI_COLORS.gray}${progressText} ${task.text}${ANSI_COLORS.reset}`, | ||
color: 'yellow' | ||
}).start(); | ||
try { | ||
await task.run(); | ||
spinner.succeed(`${ANSI_COLORS.gray}${progressText} ${task.text}${ANSI_COLORS.reset}`); | ||
} catch (error) { | ||
spinner.fail(`${ANSI_COLORS.gray}${progressText} ${task.text}${ANSI_COLORS.reset}`); | ||
allTasksSucceeded = false; | ||
} | ||
constructor(options) { | ||
this.options = options; | ||
} | ||
if (allTasksSucceeded) { | ||
console.log(`${ANSI_COLORS.green}Success!${ANSI_COLORS.white} ${this.options.successMessage}${ANSI_COLORS.reset}`); | ||
} else { | ||
console.log(`${ANSI_COLORS.red}Failed!${ANSI_COLORS.white} ${this.options.failedMessage}${ANSI_COLORS.reset}`); | ||
async runTasks() { | ||
console.log(); | ||
console.log(`${ANSI_COLORS.cyan}${this.options.startMessage}${ANSI_COLORS.reset}`); | ||
const startTime = Date.now(); | ||
const totalTasks = this.options.tasks.length; | ||
let allTasksSucceeded = true; | ||
for (let i = 0; i < totalTasks; i++) { | ||
const task = this.options.tasks[i]; | ||
const progressText = `[${i + 1}/${totalTasks}]`; | ||
const spinner = ora({ | ||
text: `${ANSI_COLORS.gray}${progressText} ${task.text}${ANSI_COLORS.reset}`, | ||
color: 'yellow' | ||
}).start(); | ||
try { | ||
await task.run(); | ||
spinner.succeed(`${ANSI_COLORS.gray}${progressText} ${task.text}${ANSI_COLORS.reset}`); | ||
} | ||
catch (error) { | ||
spinner.fail(`${ANSI_COLORS.gray}${progressText} ${task.text}${ANSI_COLORS.reset}`); | ||
allTasksSucceeded = false; | ||
} | ||
} | ||
if (allTasksSucceeded) { | ||
console.log(`${ANSI_COLORS.green}Success!${ANSI_COLORS.white} ${this.options.successMessage}${ANSI_COLORS.reset}`); | ||
} | ||
else { | ||
console.log(`${ANSI_COLORS.red}Failed!${ANSI_COLORS.white} ${this.options.failedMessage}${ANSI_COLORS.reset}`); | ||
} | ||
const endTime = Date.now(); | ||
const duration = (endTime - startTime) / 1000; | ||
console.log(`${ANSI_COLORS.blue}✨ Done in ${duration.toFixed(2)}s.${ANSI_COLORS.reset}`); | ||
console.log(); | ||
} | ||
const endTime = Date.now(); | ||
const duration = (endTime - startTime) / 1000; | ||
console.log(`${ANSI_COLORS.blue}✨ Done in ${duration.toFixed(2)}s.${ANSI_COLORS.reset}`); | ||
console.log(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters