Socket
Socket
Sign inDemoInstall

@hloth/scaffold

Package Overview
Dependencies
5
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.6 to 1.0.7

28

out/cli.js

@@ -5,9 +5,21 @@ #! /usr/bin/env node

import scaffold from './index.js';
var _process_argv_;
const projectName = (_process_argv_ = process.argv[2]) !== null && _process_argv_ !== void 0 ? _process_argv_ : (await prompts({
type: 'text',
name: 'value',
message: 'Название будушего шедевра',
validate: (value)=>!packageNameRegex.test(value) ? 'Невалидное название' : true
})).value;
await scaffold(projectName);
let projectName = process.argv[2];
let addTests = process.argv[3] === '--tests' || process.argv[3] === '--add-tests';
if (!projectName) {
const values = await prompts([
{
type: 'text',
name: 'value',
message: 'Название будушего шедевра',
validate: (value)=>!packageNameRegex.test(value) ? 'Невалидное название' : true
},
{
type: 'select',
name: 'tests',
message: 'Добавить тесты'
}
]);
projectName = values.value;
addTests = values.tests;
}
await scaffold(projectName, addTests);

@@ -0,1 +1,29 @@

function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _objectSpread(target) {
for(var i = 1; i < arguments.length; i++){
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.keys(source);
if (typeof Object.getOwnPropertySymbols === 'function') {
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
}));
}
ownKeys.forEach(function(key) {
_defineProperty(target, key, source[key]);
});
}
return target;
}
import { init } from './checks.js';

@@ -22,3 +50,3 @@ import fs from 'fs/promises';

* @returns Path to the project's dir
*/ export default async function scaffold(projectName) {
*/ export default async function scaffold(projectName, addTests) {
const dirPath = await init(projectName);

@@ -32,7 +60,9 @@ console.log(chalk.green('Генерируются файлы...'));

type: 'module',
scripts: packageJsonDefaults.scripts,
scripts: _objectSpread({}, packageJsonDefaults.scripts, addTests && {
test: 'jest'
}),
author: packageJsonDefaults.author,
license: 'MIT',
dependencies: packageJsonDefaults.dependencies,
devDependencies: packageJsonDefaults.devDependencies
devDependencies: addTests ? packageJsonDefaults.devDependenciesWithTests : packageJsonDefaults.devDependencies
};

@@ -42,6 +72,6 @@ await fs.writeFile(dirPath + 'package.json', JSON.stringify(packageJSON, null, 2), 'utf-8');

await fs.mkdir(dirPath + 'out');
await fs.mkdir(dirPath + 'types');
addTests && await fs.mkdir(dirPath + 'types');
await fs.writeFile(dirPath + 'src/index.ts', 'import \'./env.js\'\n', 'utf-8');
await fs.writeFile(dirPath + 'src/env.ts', envLoader, 'utf-8');
await fs.writeFile(dirPath + 'types/fetch.d.ts', '// eslint-disable-next-line no-var\ndeclare var fetch: typeof import(\'undici\').fetch', 'utf-8');
addTests && await fs.writeFile(dirPath + 'types/fetch.d.ts', '// eslint-disable-next-line no-var\ndeclare var fetch: typeof import(\'undici\').fetch', 'utf-8');
await fs.writeFile(dirPath + '.env', '', 'utf-8');

@@ -52,10 +82,10 @@ await fs.writeFile(dirPath + '.gitignore', gitignoreLines.join('\n'), 'utf-8');

await fs.writeFile(dirPath + 'tsconfig.json', JSON.stringify(tsconfigJson, null, 2), 'utf-8');
await fs.writeFile(dirPath + 'jest.config.js', jestConfig, 'utf-8');
await fs.writeFile(dirPath + 'babel.config.cjs', babelConfig, 'utf-8');
addTests && await fs.writeFile(dirPath + 'jest.config.js', jestConfig, 'utf-8');
addTests && await fs.writeFile(dirPath + 'babel.config.cjs', babelConfig, 'utf-8');
await fs.writeFile(dirPath + '.swcrc', JSON.stringify(swcrc, null, 2), 'utf-8');
await fs.writeFile(dirPath + 'loader.js', await fs.readFile(__dirname + '../src/templates/loader.js', 'utf-8'), 'utf-8');
await fs.writeFile(dirPath + 'loader.js', await fs.readFile(__dirname + '../src/template/loader.js', 'utf-8'), 'utf-8');
await fs.mkdir(dirPath + '.vscode');
await fs.writeFile(dirPath + '.vscode/settings.json', JSON.stringify(vscodeSettingsConfig, null, 2), 'utf-8');
await fs.mkdir(dirPath + 'test');
await fs.writeFile(dirPath + 'test/index.test.ts', '', 'utf-8');
addTests && await fs.mkdir(dirPath + 'test');
addTests && await fs.writeFile(dirPath + 'test/index.test.ts', '', 'utf-8');
console.log(chalk.green('Установка зависимостей...'));

@@ -71,3 +101,3 @@ const runSubProcess = async (command, options)=>{

});
await runSubProcess('pnpm i', {
await runSubProcess('bun install', {
cwd: dirPath

@@ -74,0 +104,0 @@ });

/* eslint-disable quotes */ export const scripts = {
"build": "rm -rf ./out/ && swc ./src -d ./out --copy-files && tsc --emitDeclarationOnly",
"start": "node --loader ./loader.js out/index.js",
"test": "jest"
"start": "node --loader ./loader.js out/index.js"
};

@@ -10,2 +9,12 @@ export const dependencies = {

export const devDependencies = {
"eslint": "^8.8.0",
"typescript": "^5.1.6",
"@types/node": "^18.17.0",
"@typescript-eslint/eslint-plugin": "^5.38.0",
"@typescript-eslint/parser": "^5.38.0",
"@swc/cli": "^0.1.57",
"@swc/core": "^1.3.18",
"undici": "^5.23.0"
};
export const devDependenciesWithTests = {
"esbuild": "^0.15.14",

@@ -12,0 +21,0 @@ "eslint": "^8.8.0",

{
"name": "@hloth/scaffold",
"version": "1.0.6",
"version": "1.0.7",
"description": "NPX tool for me to easily scaffold new project, containing TypeScript config for modern ES, eslint with my favorite code style and Jest tests with ts support",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -21,3 +21,3 @@ # Scaffold

```
npx @hloth/scaffold project-name
npx @hloth/scaffold project-name --tests
```

@@ -24,0 +24,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc