Skip to content

Commit

Permalink
feat: πŸ’„ added message output highlighting (#41)
Browse files Browse the repository at this point in the history
* feat: πŸ’„ added message output highlighting

* feat: ✨ added spinner to the output

* style: πŸ’„ formatted file

* chore: ⬆️ updated dependencies
  • Loading branch information
WasiqB authored Jan 3, 2024
1 parent 9da4d32 commit ffb521b
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 96 deletions.
19 changes: 18 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ name: Publish to NPM and GitHub

on:
workflow_dispatch:
inputs:
pre-release:
description: Is this a pre-release?
type: boolean
default: false
draft:
description: Is this a draft release?
type: boolean
default: false

jobs:
release:
Expand All @@ -18,6 +27,14 @@ jobs:
fetch-depth: 0
token: ${{ env.PUSH_TOKEN }}

- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true

- name: git config
run: |
git config user.name "${GITHUB_ACTOR}"
Expand All @@ -40,4 +57,4 @@ jobs:
run: pnpm install && pnpm build

- name: Publish to NPM and GitHub release
run: pnpm release
run: pnpm release --github.preRelease=${{ inputs.pre-release }} --github.draft=${{ inputs.draft }}
14 changes: 11 additions & 3 deletions .release-it.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,23 @@
}
},
"github": {
"release": true
"release": true,
"tokenRef": "PUSH_TOKEN",
"comments": {
"submit": true,
"issue": ":rocket: _This issue has been resolved in v${version}. See [${releaseName}](${releaseUrl}) for release notes._",
"pr": ":rocket: _This pull request is included in v${version}. See [${releaseName}](${releaseUrl}) for release notes._"
}
},
"git": {
"commit": true,
"tag": true,
"push": true,
"commitMessage": "chore: release v${version}",
"requireCleanWorkingDir": true,
"requireBranch": "main"
},
"npm": {
"publish": true,
"tokenRef": "PUSH_TOKEN"
"publish": true
}
}
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
},
"devDependencies": {
"@release-it/conventional-changelog": "^8.0.1",
"@stylistic/eslint-plugin-js": "^1.5.1",
"@stylistic/eslint-plugin-ts": "^1.5.1",
"@stylistic/eslint-plugin-js": "^1.5.3",
"@stylistic/eslint-plugin-ts": "^1.5.3",
"@tsconfig/node18": "^18.2.2",
"@types/node": "^20.10.6",
"@types/yargs": "^17.0.32",
Expand All @@ -57,6 +57,8 @@
},
"dependencies": {
"@inquirer/prompts": "^3.3.0",
"chalk": "^4.1.2",
"nanospinner": "^1.1.0",
"yargs": "^17.7.2"
},
"lint-staged": {
Expand Down
102 changes: 29 additions & 73 deletions pnpm-lock.yaml

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

16 changes: 11 additions & 5 deletions src/handler/config/init/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ import path from 'path';
import { createApiSetting } from './api';
import { createWebSetting } from './web';
import { createMobileSetting } from './mobile';
import { configFileName } from '../../../utils/constants';
import {
configFileExists,
configFileName,
configPathNotFolder,
configPathNotFound,
initMessage,
} from '../../../utils/constants';
import { getPlatform, getPlatformType } from '../../../questions/inputs';
import { FrameworkSetting } from '../../../types/configType';
import { createConfigFile } from '../../../utils/json';
Expand All @@ -16,16 +22,16 @@ export const handleConfigInit = async (argv: yargs.ArgumentsCamelCase) => {

const checkConfigFile = (configPath: string) => {
if (fs.existsSync(path.join(configPath, configFileName))) {
throw new Error(`Boyka config file is already available at [${configPath}]...`);
throw new Error(configFileExists(configPath));
}
};

const checkConfigPath = (configPath: string) => {
if (!fs.lstatSync(configPath).isDirectory()) {
throw new Error(`Config path [${configPath}] is not a folder...`);
throw new Error(configPathNotFolder(configPath));
}
if (!fs.existsSync(configPath)) {
throw new Error(`Boyka config path [${configPath}] does not exists...`);
throw new Error(configPathNotFound(configPath));
}
};

Expand All @@ -47,7 +53,7 @@ const createUiSetting = async () => {

const createConfigJson = async (configPath: string) => {
const path = configPath === '.' ? process.cwd() : configPath;
console.info(`Creating Boyka config file at ${path}...`);
console.info(initMessage(path));
validateConfigPath(path);
let setting: FrameworkSetting;
switch (await getPlatform()) {
Expand Down
45 changes: 37 additions & 8 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
import { TargetProviders } from '../types/configType';
import chalk from 'chalk';
import { TargetProviders } from '../types/configType.js';

export const epiLogMessage = `For more information,
visit: https://boykaframework.github.io/boyka-framework`;
const danger = chalk.red.bold;
const warn = chalk.yellow.bold;
const success = chalk.green.bold;
const info = chalk.blueBright.bold;

export const sleep = (ms = 2000) => new Promise((r) => setTimeout(r, ms));

export const epiLogMessage = info(`For more information,
visit: https://boykaframework.github.io/boyka-framework`);

export const configFileName = 'boyka-config.json';

export const failureMessage = (command: string = ''): string => {
const targetCommand = command.length === 0 ? '' : ` in ${command}`;
return `Something went wrong${targetCommand}! Run the command with '--help' option`;
return danger(`Something went wrong${targetCommand}! Run the command with '--help' option`);
};

let targetProviders: TargetProviders;
Expand All @@ -16,14 +24,35 @@ export const setTarget = (target: TargetProviders) => (targetProviders = target)

export const getTarget = () => targetProviders;

export const helpMessage = `
export const helpMessage = info(`
Check out the Boyka config documentation πŸ‘‰
[https://boykaframework.github.io/boyka-framework/docs/guides/configuration]
πŸ—’οΈ You can update the generated config file to include more settings πŸ› οΈ as per your requirement.
`;
`);

export const capabilitiesHelpMessage = `
export const capabilitiesHelpMessage = warn(`
❗❗ Since you have selected Cloud platform to run your tests,
you must also add cloud specific capabilities to the empty \`capabilities\` block
added to the config file.`;
added to the config file.`);

export const successMessage = (filePath: string) =>
success(`Boyka config file created at [${filePath}]`);

export const errorMessage = (error: Error) =>
danger(`Error occurred! ${error.message}
Caused by: ${error.cause}
`);

export const savingMessage = warn('Creating the [boyka-config.json] file...');

export const initMessage = (path: string) => warn(`Creating Boyka config file at ${path}...`);

export const configPathNotFound = (path: string) =>
danger(`Boyka config path [${path}] does not exists...`);

export const configPathNotFolder = (path: string) =>
danger(`Config path [${path}] is not a folder...`);

export const configFileExists = (path: string) =>
danger(`Boyka config file is already available at [${path}]...`);
Loading

0 comments on commit ffb521b

Please sign in to comment.