From a4c562f5bc3daf8ec7050297d0f6279895988ecc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A7=81Ash=C3=BB=EA=A7=82?= <30575805+Ashu11-A@users.noreply.github.com> Date: Sat, 6 Jul 2024 22:36:42 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fixing=20Enmap=20error=20with=20?= =?UTF-8?q?package.json=20file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.exemple | 0 .github/dependabot.yml | 0 .github/workflows/build-test.yml | 0 .github/workflows/build-tsc.yml | 0 .github/workflows/build-tsup.yml | 0 .github/workflows/lint.yml | 0 .gitignore | 0 CODE_OF_CONDUCT.md | 0 CONTRIBUTING.md | 0 LICENSE | 0 README.md | 0 SECURITY.md | 0 babel.config.json | 0 eslint.config.js | 0 jest.config.ts | 0 package-lock.json | 0 package.json | 14 +++++++------- src/app.ts | 2 +- src/class/pages.ts | 0 src/cli.ts | 17 +++++++++++++++++ src/controller/cloudflare.ts | 0 src/index.ts | 0 src/lib/exists.ts | 0 src/lib/extractTypes.ts | 0 src/lib/isGlobal.ts | 0 src/lib/linkTables.ts | 0 src/pages/dns.ts | 0 src/pages/dns/create.ts | 5 ++++- src/pages/options.ts | 0 src/types/page.ts | 0 test/pages/dns.test.ts | 0 test/pages/options.test.ts | 0 test/pages/zones.test.ts | 0 tsconfig.json | 0 tsup.config.ts | 0 35 files changed, 29 insertions(+), 9 deletions(-) mode change 100644 => 100755 .env.exemple mode change 100644 => 100755 .github/dependabot.yml mode change 100644 => 100755 .github/workflows/build-test.yml mode change 100644 => 100755 .github/workflows/build-tsc.yml mode change 100644 => 100755 .github/workflows/build-tsup.yml mode change 100644 => 100755 .github/workflows/lint.yml mode change 100644 => 100755 .gitignore mode change 100644 => 100755 CODE_OF_CONDUCT.md mode change 100644 => 100755 CONTRIBUTING.md mode change 100644 => 100755 LICENSE mode change 100644 => 100755 README.md mode change 100644 => 100755 SECURITY.md mode change 100644 => 100755 babel.config.json mode change 100644 => 100755 eslint.config.js mode change 100644 => 100755 jest.config.ts mode change 100644 => 100755 package-lock.json mode change 100644 => 100755 package.json mode change 100644 => 100755 src/app.ts mode change 100644 => 100755 src/class/pages.ts create mode 100755 src/cli.ts mode change 100644 => 100755 src/controller/cloudflare.ts mode change 100644 => 100755 src/index.ts mode change 100644 => 100755 src/lib/exists.ts mode change 100644 => 100755 src/lib/extractTypes.ts mode change 100644 => 100755 src/lib/isGlobal.ts mode change 100644 => 100755 src/lib/linkTables.ts mode change 100644 => 100755 src/pages/dns.ts mode change 100644 => 100755 src/pages/dns/create.ts mode change 100644 => 100755 src/pages/options.ts mode change 100644 => 100755 src/types/page.ts mode change 100644 => 100755 test/pages/dns.test.ts mode change 100644 => 100755 test/pages/options.test.ts mode change 100644 => 100755 test/pages/zones.test.ts mode change 100644 => 100755 tsconfig.json mode change 100644 => 100755 tsup.config.ts diff --git a/.env.exemple b/.env.exemple old mode 100644 new mode 100755 diff --git a/.github/dependabot.yml b/.github/dependabot.yml old mode 100644 new mode 100755 diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml old mode 100644 new mode 100755 diff --git a/.github/workflows/build-tsc.yml b/.github/workflows/build-tsc.yml old mode 100644 new mode 100755 diff --git a/.github/workflows/build-tsup.yml b/.github/workflows/build-tsup.yml old mode 100644 new mode 100755 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml old mode 100644 new mode 100755 diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md old mode 100644 new mode 100755 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md old mode 100644 new mode 100755 diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/SECURITY.md b/SECURITY.md old mode 100644 new mode 100755 diff --git a/babel.config.json b/babel.config.json old mode 100644 new mode 100755 diff --git a/eslint.config.js b/eslint.config.js old mode 100644 new mode 100755 diff --git a/jest.config.ts b/jest.config.ts old mode 100644 new mode 100755 diff --git a/package-lock.json b/package-lock.json old mode 100644 new mode 100755 diff --git a/package.json b/package.json old mode 100644 new mode 100755 index 63ca02d..750e168 --- a/package.json +++ b/package.json @@ -2,8 +2,8 @@ "name": "cloudflare-manager", "version": "1.0.0", "description": "Gerenciador de fácil uso para cloudflare", - "main": "dist/app.js", - "module": "dist/app.js", + "main": "dist/cli.js", + "module": "dist/cli.js", "type": "module", "homepage": "https://github.com/Ashu11-A/cloudflare-manager", "repository": { @@ -11,8 +11,8 @@ }, "exports": { ".": { - "import": "./dist/app.js", - "types": "./dist/app.d.ts" + "import": "./dist/cli.js", + "types": "./dist/cli.d.ts" } }, "imports": { @@ -24,9 +24,9 @@ "node": ">=20" }, "bin": { - "cloudflare-manager": "dist/app.js", - "cfm": "dist/app.js", - "cm": "dist/app.js" + "cloudflare-manager": "dist/cli.js", + "cfm": "dist/cli.js", + "cm": "dist/cli.js" }, "scripts": { "build": "rimraf dist && tsc && tsc-alias", diff --git a/src/app.ts b/src/app.ts old mode 100644 new mode 100755 index 42ce561..924892e --- a/src/app.ts +++ b/src/app.ts @@ -1,7 +1,7 @@ +import c from 'chalk' import { Page } from './class/pages.js' import { page } from './index.js' import { isGlobal } from './lib/isGlobal.js' -import c from 'chalk' if (!(await isGlobal())) { console.log(`⚠️ ${c.red('Warning')}!`) diff --git a/src/class/pages.ts b/src/class/pages.ts old mode 100644 new mode 100755 diff --git a/src/cli.ts b/src/cli.ts new file mode 100755 index 0000000..a55a1d2 --- /dev/null +++ b/src/cli.ts @@ -0,0 +1,17 @@ +#!/usr/bin/env node +import { writeFile } from 'fs/promises' +import { join } from 'path' +import { exists } from './lib/exists.js' + +const pkgPath = join(process.cwd(), 'package.json') + +if (!(await exists(pkgPath))) { + await writeFile(pkgPath, JSON.stringify({ + version: '1.0.0', + description: 'Generated by cloudflare-manager, for the enmap to work!' + }, null, 2), { + encoding: 'utf-8' + }) +} + +await import('./app.js') \ No newline at end of file diff --git a/src/controller/cloudflare.ts b/src/controller/cloudflare.ts old mode 100644 new mode 100755 diff --git a/src/index.ts b/src/index.ts old mode 100644 new mode 100755 diff --git a/src/lib/exists.ts b/src/lib/exists.ts old mode 100644 new mode 100755 diff --git a/src/lib/extractTypes.ts b/src/lib/extractTypes.ts old mode 100644 new mode 100755 diff --git a/src/lib/isGlobal.ts b/src/lib/isGlobal.ts old mode 100644 new mode 100755 diff --git a/src/lib/linkTables.ts b/src/lib/linkTables.ts old mode 100644 new mode 100755 diff --git a/src/pages/dns.ts b/src/pages/dns.ts old mode 100644 new mode 100755 diff --git a/src/pages/dns/create.ts b/src/pages/dns/create.ts old mode 100644 new mode 100755 index 1eff5cc..9f74c7d --- a/src/pages/dns/create.ts +++ b/src/pages/dns/create.ts @@ -4,6 +4,8 @@ import { client, zone } from '@/index.js' import { extractTypes, Properties } from '@/lib/extractTypes.js' import { PageTypes } from '@/types/page.js' import chalk from 'chalk' +import { __dirname } from '@/index.js' +import { join } from 'path' enum RecordsType { ARecord = 'A', @@ -55,7 +57,8 @@ new Page({ * Isso converte as tipagens do cloudflare. * @returns {Record | undefined} */ - const properties = extractTypes('node_modules/cloudflare/src/resources/dns/records.ts', record) + const pathToCloudflare = join(__dirname, '../', 'node_modules/cloudflare/src/resources/dns/records.ts') + const properties = extractTypes(pathToCloudflare, record) if (properties === undefined) throw new Error(`Não foi possivel achar os types de ${record}`) /** diff --git a/src/pages/options.ts b/src/pages/options.ts old mode 100644 new mode 100755 diff --git a/src/types/page.ts b/src/types/page.ts old mode 100644 new mode 100755 diff --git a/test/pages/dns.test.ts b/test/pages/dns.test.ts old mode 100644 new mode 100755 diff --git a/test/pages/options.test.ts b/test/pages/options.test.ts old mode 100644 new mode 100755 diff --git a/test/pages/zones.test.ts b/test/pages/zones.test.ts old mode 100644 new mode 100755 diff --git a/tsconfig.json b/tsconfig.json old mode 100644 new mode 100755 diff --git a/tsup.config.ts b/tsup.config.ts old mode 100644 new mode 100755