Skip to content

Commit

Permalink
fix: switching to chalk instead of colors (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
YassinEldeeb committed Jan 9, 2022
1 parent 6271c3c commit b01a11e
Show file tree
Hide file tree
Showing 6 changed files with 164 additions and 210 deletions.
266 changes: 127 additions & 139 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,148 +7,136 @@ on:
branches: ['*']

jobs:
# unit-tests:
# runs-on: ${{ matrix.os }}
# strategy:
# matrix:
# node-version: [14.x, 15.x, 16.x, 17.x]
# os: [ubuntu-latest, windows-latest]

# steps:
# - uses: actions/checkout@v2
# with:
# fetch-depth: 100
# - name: Use Node.js ${{matrix.node-version}}
# uses: actions/setup-node@v2
# with:
# node-version: ${{ matrix.node-version }}

# - uses: YassinEldeeb/has-changed-path@v2.1
# id: changed-packages
# with:
# paths: packages

# - name: Setup PNPM
# if: steps.changed-packages.outputs.changed == 'true'
# uses: pnpm/action-setup@v2.0.1
# with:
# version: 6.23.6

# - name: Simulate CLI build
# if: steps.changed-packages.outputs.changed == 'true'
# run: pnpm simulate-dist

# - name: Install dependencies
# if: steps.changed-packages.outputs.changed == 'true'
# run: pnpm i --frozen-lockfile

# - name: Run Tests 🧪
# if: steps.changed-packages.outputs.changed == 'true'
# working-directory: ./packages/create-prisma-generator
# run: pnpm test -- --testPathIgnorePatterns e2e

# e2e-tests:
# runs-on: ${{ matrix.os }}
# needs: [unit-tests]
# strategy:
# matrix:
# node-version: [16.x]
# os: [ubuntu-latest, windows-latest, macos-latest]

# steps:
# - uses: actions/checkout@v2
# with:
# fetch-depth: 100
# - name: Use Node.js ${{matrix.node-version}}
# uses: actions/setup-node@v2
# with:
# node-version: ${{ matrix.node-version }}

# - uses: YassinEldeeb/has-changed-path@v2.1
# id: changed-packages
# with:
# paths: packages

# - name: Tell git who am I
# if: steps.changed-packages.outputs.changed == 'true'
# run: |
# git config --global user.name "me"
# git config --global user.email "me@example.com"

# - name: Setup PNPM
# if: steps.changed-packages.outputs.changed == 'true'
# uses: pnpm/action-setup@v2.0.1
# with:
# version: 6.23.6

# - name: Simulate CLI build
# if: steps.changed-packages.outputs.changed == 'true'
# run: pnpm simulate-dist

# - name: Install dependencies
# if: steps.changed-packages.outputs.changed == 'true'
# run: pnpm i --frozen-lockfile

# - name: Run E2E Tests 🧪
# if: steps.changed-packages.outputs.changed == 'true'
# working-directory: ./packages/create-prisma-generator
# run: pnpm test -- --testPathPattern e2e

# Publish:
# runs-on: ubuntu-latest
# if: ${{ github.ref == 'refs/heads/main' }}
# needs: [unit-tests, e2e-tests]

# steps:
# - uses: actions/checkout@v2
# with:
# fetch-depth: 100
# - name: Use Node.js
# uses: actions/setup-node@v2
# with:
# node-version: 16.x
# registry-url: https://registry.npmjs.org

# - uses: YassinEldeeb/has-changed-path@v2.1
# id: changed-packages
# with:
# paths: packages

# - name: Setup PNPM
# uses: pnpm/action-setup@v2.0.1
# if: steps.changed-packages.outputs.changed == 'true'
# with:
# version: 6.23.6

# - uses: actions/cache@v2
# if: steps.changed-packages.outputs.changed == 'true'
# with:
# path: '**/node_modules'
# key: ${{ runner.os }}-modules-${{ hashFiles('**/pnpm-lock.yaml') }}

# - name: Simulate CLI build
# if: steps.changed-packages.outputs.changed == 'true'
# run: pnpm simulate-dist

# - name: Install deps
# if: steps.changed-packages.outputs.changed == 'true'
# run: pnpm i --frozen-lockfile

# - name: Publish 🚀
# if: steps.changed-packages.outputs.changed == 'true'
# run: |
# GITHUB_TOKEN="${{secrets.GITHUB_TOKEN}}" GIT_COMMITTER_EMAIL="${{secrets.GIT_COMMITTER_EMAIL}}" GIT_COMMITTER_NAME="${{secrets.GIT_COMMITTER_NAME}}" npx ts-node ./scripts/ci/publish.ts
# env:
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

debugging-issue:
runs-on: macos-latest
unit-tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [14.x, 15.x, 16.x, 17.x]
os: [ubuntu-latest, windows-latest]

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 100
- name: Use Node.js ${{matrix.node-version}}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

- uses: YassinEldeeb/has-changed-path@v2.1
id: changed-packages
with:
paths: packages

- name: Setup PNPM
if: steps.changed-packages.outputs.changed == 'true'
uses: pnpm/action-setup@v2.0.1
with:
version: 6.23.6

- name: Simulate CLI build
if: steps.changed-packages.outputs.changed == 'true'
run: pnpm simulate-dist

- name: Install dependencies
if: steps.changed-packages.outputs.changed == 'true'
run: pnpm i --frozen-lockfile

- name: Run Tests 🧪
if: steps.changed-packages.outputs.changed == 'true'
working-directory: ./packages/create-prisma-generator
run: pnpm test -- --testPathIgnorePatterns e2e

e2e-tests:
runs-on: ${{ matrix.os }}
needs: [unit-tests]
strategy:
matrix:
node-version: [16.x]
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 100
- name: Use Node.js ${{matrix.node-version}}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

- uses: YassinEldeeb/has-changed-path@v2.1
id: changed-packages
with:
paths: packages

- name: Tell git who am I
if: steps.changed-packages.outputs.changed == 'true'
run: |
git config --global user.name "me"
git config --global user.email "me@example.com"
- name: Setup PNPM
if: steps.changed-packages.outputs.changed == 'true'
uses: pnpm/action-setup@v2.0.1
with:
version: 6.23.6

- name: Simulate CLI build
if: steps.changed-packages.outputs.changed == 'true'
run: pnpm simulate-dist

- name: Install dependencies
if: steps.changed-packages.outputs.changed == 'true'
run: pnpm i --frozen-lockfile

- name: Run E2E Tests 🧪
if: steps.changed-packages.outputs.changed == 'true'
working-directory: ./packages/create-prisma-generator
run: pnpm test -- --testPathPattern e2e

Publish:
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/main' }}
needs: [unit-tests, e2e-tests]

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
fetch-depth: 100
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: 16.x
registry-url: https://registry.npmjs.org

- uses: YassinEldeeb/has-changed-path@v2.1
id: changed-packages
with:
paths: packages

- name: Setup PNPM
uses: pnpm/action-setup@v2.0.1
if: steps.changed-packages.outputs.changed == 'true'
with:
version: 6.23.6

- uses: actions/cache@v2
if: steps.changed-packages.outputs.changed == 'true'
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/pnpm-lock.yaml') }}

- name: Simulate CLI build
if: steps.changed-packages.outputs.changed == 'true'
run: pnpm simulate-dist

- name: Install deps
if: steps.changed-packages.outputs.changed == 'true'
run: pnpm i --frozen-lockfile

- name: Debugging
- name: Publish 🚀
if: steps.changed-packages.outputs.changed == 'true'
run: |
npx create-prisma-generator
GITHUB_TOKEN="${{secrets.GITHUB_TOKEN}}" GIT_COMMITTER_EMAIL="${{secrets.GIT_COMMITTER_EMAIL}}" GIT_COMMITTER_NAME="${{secrets.GIT_COMMITTER_NAME}}" npx ts-node ./scripts/ci/publish.ts
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
3 changes: 1 addition & 2 deletions packages/create-prisma-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"dependencies": {
"@types/fs-extra": "^9.0.13",
"colors": "^1.4.0",
"chalk": "4.1.2",
"fs-extra": "^10.0.0",
"inquirer": "^8.2.0",
"rimraf": "^3.0.2",
Expand All @@ -30,7 +30,6 @@
"devDependencies": {
"@alex_neo/jest-expect-message": "^1.0.5",
"@nut-tree/nut-js": "^2.0.0-RC1",
"@types/colors": "^1.2.1",
"@types/inquirer": "^8.1.3",
"@types/jest": "^27.0.3",
"@types/jest-expect-message": "^1.0.3",
Expand Down
23 changes: 10 additions & 13 deletions packages/create-prisma-generator/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { execSync, spawnSync } from 'child_process'
import colors from 'colors'
import chalk from 'chalk'
import fs from 'fs'
import path from 'path'
import { runBlockingCommand } from './utils/runBlockingCommand'
Expand Down Expand Up @@ -27,21 +27,21 @@ export const main = async () => {

// Validate if folder with the same name doesn't exist
if (fs.existsSync(projectWorkdir)) {
console.log(colors.red(`${pkgName} directory already exists!`))
console.log(chalk.red(`${pkgName} directory already exists!`))
return
}

console.log(
'\nCreating a new Prisma generator in',
colors.cyan(path.join(projectWorkdir)) + '.\n',
chalk.cyan(path.join(projectWorkdir)) + '.\n',
)

// Initialize git
//! This needs to be at the top cause `husky` won't run
//! if there was no repository
fs.mkdirSync(projectWorkdir, { recursive: true })
execSync(`${workingDir} && git init`)
console.log(colors.cyan('\nInitialized a git repository.\n'))
console.log(chalk.cyan('\nInitialized a git repository.\n'))

// Adding default root configs
const templateName = 'root default configs'
Expand Down Expand Up @@ -123,10 +123,7 @@ export const main = async () => {
'',
)

console.log(
colors.cyan(`${pkgManager} Workspace`),
'configured correctly\n',
)
console.log(chalk.cyan(`${pkgManager} Workspace`), 'configured correctly\n')
}

//! Should be after initializing the workspace
Expand All @@ -142,7 +139,7 @@ export const main = async () => {
)
}

console.log(colors.cyan(`Installing dependencies using ${pkgManager}\n`))
console.log(chalk.cyan(`Installing dependencies using ${pkgManager}\n`))

// Install packages
spawnSync(getInstallCommand(pkgManager), {
Expand All @@ -166,7 +163,7 @@ export const main = async () => {
execSync(
`${workingDir} && git checkout -b main && git add . && git commit -m"init"`,
)
console.log(colors.cyan('Created git commit.\n'))
console.log(chalk.cyan('Created git commit.\n'))

// Add commit-msg husky hook to lint commits
// using commitlint before they are created
Expand All @@ -186,10 +183,10 @@ export const main = async () => {
}

// Success Messages
console.log(colors.green(`Success!`), `Created ${projectWorkdir}`)
console.log(chalk.green(`Success!`), `Created ${projectWorkdir}`)
console.log(`We suggest that you begin by typing:\n`)
console.log(colors.cyan('cd'), pkgName)
console.log(colors.cyan('code .'))
console.log(chalk.cyan('cd'), pkgName)
console.log(chalk.cyan('code .'))
console.log(`\nStart Generating ;)`)

return answers
Expand Down

0 comments on commit b01a11e

Please sign in to comment.