From c7635806785a62c9759fd3c91c9907fda5eccfc8 Mon Sep 17 00:00:00 2001 From: ChrisKader Date: Mon, 23 Sep 2024 06:01:48 -0500 Subject: [PATCH] Updates --- index.js | 37 ++++++++++++++++--------------------- tsconfig.json | 4 ++-- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/index.js b/index.js index 3e6e950..631f71a 100644 --- a/index.js +++ b/index.js @@ -1,17 +1,12 @@ #!/usr/bin/env node -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const prompts_1 = __importDefault(require("prompts")); -const lodash_kebabcase_1 = __importDefault(require("lodash.kebabcase")); -const sanitize_filename_1 = __importDefault(require("sanitize-filename")); -const util_1 = __importDefault(require("util")); -const fs_extra_1 = __importDefault(require("fs-extra")); -const path_1 = __importDefault(require("path")); -const sort_package_json_1 = require("sort-package-json"); -const exec = util_1.default.promisify(require('child_process').exec); +import prompts from 'prompts'; +import kebabCase from 'lodash.kebabcase'; +import sanitize from 'sanitize-filename'; +import util from 'util'; +import fs from 'fs-extra'; +import path from 'path'; +import { sortPackageJson } from 'sort-package-json'; +const exec = util.promisify(require('child_process').exec); const repoUrls = { js: 'https://git.tinkr.site/jeffi/js-tinkrplugin-boilerplate.git', ts: 'https://git.tinkr.site/jeffi/ts-tinkr-plugin-boilerplate.git', @@ -23,7 +18,7 @@ const invalidVersion = ` A valid version has one to four dot-separated integers. Examples: "1", "1.0", "2.0.3", "3.4.7.219" `.trim(); -(0, prompts_1.default)([ +prompts([ { type: 'text', name: 'name', @@ -58,21 +53,21 @@ Examples: "1", "1.0", "2.0.3", "3.4.7.219" initial: 0, }, ]).then(async ({ name, version, author, description, lang }) => { - const packageName = (0, lodash_kebabcase_1.default)((0, sanitize_filename_1.default)(name, { replacement: '-' })); + const packageName = kebabCase(sanitize(name, { replacement: '-' })); console.log(`Creating a Tinkr plugin in ./${packageName}`); await exec(`git clone ${repoUrls[lang]} ${packageName}`); - const packageDir = path_1.default.join(process.cwd(), packageName); - const packageJsonPath = path_1.default.join(packageDir, 'package.json'); - const { bugs, homepage, keywords, license, repository, ...packageJson } = await fs_extra_1.default.readJSON(packageJsonPath); - await fs_extra_1.default.writeJSON(packageJsonPath, (0, sort_package_json_1.sortPackageJson)({ + const packageDir = path.join(process.cwd(), packageName); + const packageJsonPath = path.join(packageDir, 'package.json'); + const { bugs, homepage, keywords, license, repository, ...packageJson } = await fs.readJSON(packageJsonPath); + await fs.writeJSON(packageJsonPath, sortPackageJson({ ...packageJson, author, description, name: packageName, version, }), { spaces: 2 }); - const gitFolderPath = path_1.default.join(packageDir, '.git'); - await fs_extra_1.default.remove(gitFolderPath); + const gitFolderPath = path.join(packageDir, '.git'); + await fs.remove(gitFolderPath); console.log('Success: Now just `npm install` using your favorite package manager and create your Tinkr plugin!'); }).catch((error) => { console.error(error); diff --git a/tsconfig.json b/tsconfig.json index 0d7fc32..4d72338 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -25,9 +25,9 @@ // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ /* Modules */ - "module": "CommonJS", /* Specify what module code is generated. */ + "module": "ESNext", /* Specify what module code is generated. */ "rootDir": "./src", /* Specify the root folder within your source files. */ - "moduleResolution": "Node", /* Specify how TypeScript looks up a file from a given module specifier. */ + "moduleResolution": "Bundler", /* Specify how TypeScript looks up a file from a given module specifier. */ // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */