Skip to content

Commit

Permalink
feat: Initial CLI Setup (#1)
Browse files Browse the repository at this point in the history
* Initial CLI Setup

* Github publish action

* Only publish on push to main

* Workflow

* fix: Add Readme

* fix: Troubleshoot

* fix: Troubleshoot workflow

* fix: Troubleshoot workflow

* fix: Troubleshoot workflow

* fix: Troubleshoot workflow

* fix: Troubleshoot workflow

* chore(release): set `package.json` to 1.0.0 [skip ci]

# 1.0.0 (2023-05-11)

### Bug Fixes

* Add Readme ([7bd6115](7bd6115))
* Troubleshoot ([ac95d1c](ac95d1c))
* Troubleshoot workflow ([637c8f0](637c8f0))
* Troubleshoot workflow ([1634868](1634868))
* Troubleshoot workflow ([8ab54cc](8ab54cc))
* Troubleshoot workflow ([e5a3df1](e5a3df1))
* Troubleshoot workflow ([951c61e](951c61e))

* fix: Troubleshoot workflow

* chore(release): set `package.json` to 1.0.1 [skip ci]

## [1.0.1](v1.0.0...v1.0.1) (2023-05-11)

### Bug Fixes

* Troubleshoot workflow ([0ba8ccb](0ba8ccb))

* Fixed

---------

Co-authored-by: semantic-release-bot <semantic-release-bot@martynus.net>
  • Loading branch information
bcanfield and semantic-release-bot authored May 11, 2023
1 parent c8f3e1e commit aeb32ba
Show file tree
Hide file tree
Showing 11 changed files with 275 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: "publish package to npm"

on: push

jobs:
release:
name: Release
runs-on: ubuntu-latest

permissions:
packages: write
contents: write

steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 18.x
- name: Install dependencies
run: npx ci
- name: Install semantic-release extra plugins
run: npm install --save-dev @semantic-release/changelog @semantic-release/git
- name: Build
run: npm run build
- name: Create .npmrc file
run: |
echo registry=https://registry.npmjs.org/ > .npmrc
echo @uzenith360:registry=https://npm.pkg.github.com/ > .npmrc
echo '//npm.pkg.github.com/:_authToken=${{ secrets.GH_TOKEN }}' >> .npmrc
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPMAUTHTOKEN }}
run: npx semantic-release
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/

# TypeScript cache
*.tsbuildinfo\
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## [1.0.1](https://github.com/bcanfield/prisnext/compare/v1.0.0...v1.0.1) (2023-05-11)


### Bug Fixes

* Troubleshoot workflow ([0ba8ccb](https://github.com/bcanfield/prisnext/commit/0ba8ccbd5e2ad5973dc555a9674af00255571400))

# 1.0.0 (2023-05-11)


### Bug Fixes

* Add Readme ([7bd6115](https://github.com/bcanfield/prisnext/commit/7bd6115f8521eb095faee989589d61f5a520305f))
* Troubleshoot ([ac95d1c](https://github.com/bcanfield/prisnext/commit/ac95d1cb3feefeb7523b3151a4d9b0593965c92e))
* Troubleshoot workflow ([637c8f0](https://github.com/bcanfield/prisnext/commit/637c8f00031dc060ea6199c6708f551ea30f3cd6))
* Troubleshoot workflow ([1634868](https://github.com/bcanfield/prisnext/commit/1634868e43bec360022ed525dd7751eb2ed53ded))
* Troubleshoot workflow ([8ab54cc](https://github.com/bcanfield/prisnext/commit/8ab54cc28e8734e6623335ade4ccaaf38101a63e))
* Troubleshoot workflow ([e5a3df1](https://github.com/bcanfield/prisnext/commit/e5a3df162ad8c16bc9279b6ed70da22ac9942e1c))
* Troubleshoot workflow ([951c61e](https://github.com/bcanfield/prisnext/commit/951c61e7d46556e9f40f48024a480ac67c72fa29))
Empty file added README.md
Empty file.
47 changes: 47 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 59 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "prisnext",
"version": "0.0.0-semantic-release",
"description": "Generate Next.js components from your Prisma Schema",
"main": "dist/index.js",
"repository": "https://github.com/bcanfield/prisnext",
"bin": {
"prisnext": "./dist/index.js"
},
"scripts": {
"build": "npx tsc",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Brandin Canfield",
"license": "MIT",
"keywords": [
"Prisma",
"TypeScript",
"Next.js",
"React"
],
"dependencies": {
"commander": "^10.0.1",
"figlet": "^1.6.0"
},
"devDependencies": {
"@types/node": "^20.1.2",
"typescript": "^5.0.4"
}
}
28 changes: 28 additions & 0 deletions release.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module.exports = {
branches: [
'main',
{
name: 'beta',
prerelease: true
}
],
plugins: [
'@semantic-release/commit-analyzer',
'@semantic-release/release-notes-generator',
[
'@semantic-release/changelog',
{
changelogFile: 'CHANGELOG.md'
}
],
'@semantic-release/npm',
'@semantic-release/github',
[
'@semantic-release/git',
{
assets: ['CHANGELOG.md', 'dist/**'],
message: 'chore(release): set `package.json` to ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}'
}
]
]
}
37 changes: 37 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#! /usr/bin/env node
const { Command } = require("commander");
const figlet = require("figlet");
const fs = require("fs");
const path = require("path");

async function listDirContents(filepath: string) {
try {
const files = await fs.promises.readdir(filepath);
const detailedFilesPromises = files.map(async (file: string) => {
let fileDetails = await fs.promises.lstat(path.resolve(filepath, file));
const { size, birthtime } = fileDetails;
return { filename: file, "size(KB)": size, created_at: birthtime };
});
const detailedFiles = await Promise.all(detailedFilesPromises);
console.table(detailedFiles);
} catch (error) {
console.error("Error occurred while reading the directory!", error);
}
}
const program = new Command();

console.log(figlet.textSync("Prisnext"));
program
.version("1.0.0")
.description("An example CLI for managing a directory")
.option("-l, --ls [value]", "List directory contents")
.option("-m, --mkdir <value>", "Create a directory")
.option("-t, --touch <value>", "Create a file")
.parse(process.argv);

const options = program.opts();

if (options.ls) {
const filepath = typeof options.ls === "string" ? options.ls : __dirname;
listDirContents(filepath);
}
12 changes: 12 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"rootDir": "src",
"outDir": "dist",
"strict": true,
"target": "es6",
"module": "commonjs",
"sourceMap": true,
"esModuleInterop": true,
"moduleResolution": "node"
}
}

0 comments on commit aeb32ba

Please sign in to comment.