Skip to content

Commit

Permalink
chore: move to spaces again! forever!
Browse files Browse the repository at this point in the history
Signed-off-by: tunnckoCore <[email protected]>
  • Loading branch information
tunnckoCore committed Jul 15, 2022
1 parent 99f2878 commit 41fc253
Show file tree
Hide file tree
Showing 173 changed files with 9,083 additions and 9,014 deletions.
72 changes: 71 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,72 @@
CHANGELOG.md
hela-workspace.json
fixtures
*.tsbuildinfo
*.*cache

# Build environment
dist

# Package managers lockfiles
package-lock.json
shrinkwrap.json
pnpm-lock.json

# Logs
logs
*.log
*~

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# next.js build output
.next
116 changes: 58 additions & 58 deletions @hela/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,60 +1,60 @@
{
"name": "@hela/cli",
"version": "4.0.2",
"licenseStart": 2017,
"license": "MPL-2.0",
"description": "Hela v4. Powerful, simple and fast software development and management system.",
"author": "Charlike Mike Reagent <[email protected]>",
"homepage": "https://github.com/tunnckoCore/opensource/tree/master/@hela/cli",
"funding": [
"https://ko-fi.com/tunnckoCore/commissions",
"https://github.com/sponsors/tunnckoCore"
],
"repository": {
"type": "git",
"url": "https://github.com/tunnckoCore/opensource.git",
"directory": "@hela/cli"
},
"type": "module",
"main": "src/index.js",
"files": [
"src"
],
"bin": {
"hela": "src/bin.js",
"hela-cli": "src/bin.js"
},
"engines": {
"node": ">=16 <17 || >=18 <19 || >=20"
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org",
"tag": "latest"
},
"scripts": {},
"dependencies": {
"@hela/core": "*"
},
"keywords": [
"tunnckocorehq",
"tunnckocore-oss",
"hela",
"development",
"developer-experience",
"dx",
"monorepos",
"tooling",
"software development",
"jest",
"jest system",
"build system",
"monorepo tools",
"multirepo",
"jest build",
"management"
],
"contributors": [
"Charlike Mike Reagent <[email protected]>"
]
"name": "@hela/cli",
"version": "4.0.2",
"licenseStart": 2017,
"license": "MPL-2.0",
"description": "Hela v4. Powerful, simple and fast software development and management system.",
"author": "Charlike Mike Reagent <[email protected]>",
"homepage": "https://github.com/tunnckoCore/opensource/tree/master/@hela/cli",
"funding": [
"https://ko-fi.com/tunnckoCore/commissions",
"https://github.com/sponsors/tunnckoCore"
],
"repository": {
"type": "git",
"url": "https://github.com/tunnckoCore/opensource.git",
"directory": "@hela/cli"
},
"type": "module",
"main": "src/index.js",
"files": [
"src"
],
"bin": {
"hela": "src/bin.js",
"hela-cli": "src/bin.js"
},
"engines": {
"node": ">=16 <17 || >=18 <19 || >=20"
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org",
"tag": "latest"
},
"scripts": {},
"dependencies": {
"@hela/core": "*"
},
"keywords": [
"tunnckocorehq",
"tunnckocore-oss",
"hela",
"development",
"developer-experience",
"dx",
"monorepos",
"tooling",
"software development",
"jest",
"jest system",
"build system",
"monorepo tools",
"multirepo",
"jest build",
"management"
],
"contributors": [
"Charlike Mike Reagent <[email protected]>"
]
}
4 changes: 2 additions & 2 deletions @hela/cli/src/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import cli from './index.js';

try {
await cli();
await cli();
} catch (err) {
console.error('[hela] Failure!', err.stack);
console.error('[hela] Failure!', err.stack);
}
42 changes: 21 additions & 21 deletions @hela/cli/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,34 @@ import { hela, utils } from '@hela/core';
import { loadConfig, tryLoadFromPackageJson } from './utils.js';

const argv = utils.parseArgv(process.argv.slice(2), {
default: {
// a duplicate of below `.option`s
cwd: process.cwd(),
showStack: false,
verbose: false,
config: 'hela.config.js',
},
alias: {
config: ['c'],
},
default: {
// a duplicate of below `.option`s
cwd: process.cwd(),
showStack: false,
verbose: false,
config: 'hela.config.js',
},
alias: {
config: ['c'],
},
});

const prog = hela({ argv });

prog
.option('--cwd', 'some global flag', argv.cwd)
.option('--verbose', 'Print more verbose output', false)
.option('--showStack', 'Show more detailed info when errors', false)
.option('-c, --config', 'Path to config file', 'hela.config.js');
.option('--cwd', 'some global flag', argv.cwd)
.option('--verbose', 'Print more verbose output', false)
.option('--showStack', 'Show more detailed info when errors', false)
.option('-c, --config', 'Path to config file', 'hela.config.js');

export default async function main() {
const helaConfig = tryLoadFromPackageJson(argv);
const cfg = await loadConfig(helaConfig ?? argv.config, argv, prog);
const helaConfig = tryLoadFromPackageJson(argv);
const cfg = await loadConfig(helaConfig ?? argv.config, argv, prog);

// if local config file is loaded, or a package from `extends`
if (cfg.filepath.includes('node_modules') || cfg.filepath.endsWith('.js')) {
prog.extendWith(cfg.config);
}
// if local config file is loaded, or a package from `extends`
if (cfg.filepath.includes('node_modules') || cfg.filepath.endsWith('.js')) {
prog.extendWith(cfg.config);
}

return prog.parse();
return prog.parse();
}
106 changes: 53 additions & 53 deletions @hela/cli/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,67 +5,67 @@ import fs from 'node:fs';
import { HelaError } from '@hela/core';

export function isObject(val) {
return val && typeof val === 'object' && Array.isArray(val) === false;
return val && typeof val === 'object' && Array.isArray(val) === false;
}

export function readJSON(filepath) {
return JSON.parse(fs.readFileSync(filepath, 'utf8'));
return JSON.parse(fs.readFileSync(filepath, 'utf8'));
}

export function tryLoadFromPackageJson(argv) {
const pkg = readJSON(path.join(argv.cwd, 'package.json'));
const pkg = readJSON(path.join(argv.cwd, 'package.json'));

return pkg.hela;
return pkg.hela;
}

export async function loadConfig(cfgName, argv, prog) {
let cfg = null;

// case because we don't yet have the prog's -c, --config parsed
// name = name || "hela.config.js";

const isFilepath = String(cfgName).endsWith('.js');
const name = isFilepath ? path.join(argv.cwd, cfgName) : cfgName;

try {
cfg = await import(name);
} catch (err) {
throw new HelaError(`Failed to load config: ${name}. Error: ${err.stack}`);
}

// if it's a promise, e.g. a promise resolving to object
cfg = await cfg;

if (cfg.default) {
if (typeof cfg.default === 'string') {
// eslint-disable-next-line unicorn/no-await-expression-member
cfg = (await loadConfig(cfg.default, argv, prog)).config;
}

if (typeof cfg.default === 'function') {
cfg = await cfg.default(prog);
// eslint-disable-next-line promise/prefer-await-to-then
} else if (cfg.default && cfg.default.then && cfg.default.catch) {
cfg = await cfg.default;

if (typeof cfg.default === 'function') {
cfg = await cfg.default(prog);
}
}
}

cfg = await cfg;

const res = {
config: cfg,
filepath: isFilepath
? path.join(argv.cwd, name)
: path.join(argv.cwd, 'node_modules', name),
};

if (argv.verbose) {
console.log('[info] hela: Loading config ->', name);
}

return res;
let cfg = null;

// case because we don't yet have the prog's -c, --config parsed
// name = name || "hela.config.js";

const isFilepath = String(cfgName).endsWith('.js');
const name = isFilepath ? path.join(argv.cwd, cfgName) : cfgName;

try {
cfg = await import(name);
} catch (err) {
throw new HelaError(`Failed to load config: ${name}. Error: ${err.stack}`);
}

// if it's a promise, e.g. a promise resolving to object
cfg = await cfg;

if (cfg.default) {
if (typeof cfg.default === 'string') {
// eslint-disable-next-line unicorn/no-await-expression-member
cfg = (await loadConfig(cfg.default, argv, prog)).config;
}

if (typeof cfg.default === 'function') {
cfg = await cfg.default(prog);
// eslint-disable-next-line promise/prefer-await-to-then
} else if (cfg.default && cfg.default.then && cfg.default.catch) {
cfg = await cfg.default;

if (typeof cfg.default === 'function') {
cfg = await cfg.default(prog);
}
}
}

cfg = await cfg;

const res = {
config: cfg,
filepath: isFilepath
? path.join(argv.cwd, name)
: path.join(argv.cwd, 'node_modules', name),
};

if (argv.verbose) {
console.log('[info] hela: Loading config ->', name);
}

return res;
}
2 changes: 1 addition & 1 deletion @hela/cli/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import test from 'asia';
import mod from '../src/index.js';

test('todo tests for @hela/cli package', async () => {
assert.equal(typeof mod, 'function');
assert.equal(typeof mod, 'function');
});
Loading

0 comments on commit 41fc253

Please sign in to comment.