Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions esbuild.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import * as esbuild from "esbuild";

/**
* @type {esbuild.BuildOptions}
*/
const config = {
entryPoints: ["lib/ditto.ts"],
bundle: true,
metafile: true,
keepNames: true,
tsconfig: "tsconfig.json",
sourcemap: process.env.ENV === "production" ? "external" : "both",
minify: process.env.ENV === "production",
outdir: "bin",
target: "es2020",
packages: "external",
platform: "node",
};

async function main() {
const result = await esbuild.build(config);
// Output build metafile so we can analyze the bundle
// size over time and check if anything unexpected is being bundled in.
if (process.env.ENV === "production") {
console.log(
await esbuild.analyzeMetafile(result.metafile, {
verbose: true,
})
);
}
}

main();
13 changes: 0 additions & 13 deletions etsc.config.js

This file was deleted.

3 changes: 0 additions & 3 deletions lib/ditto.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#!/usr/bin/env node
// This is the main entry point for the ditto-cli command.

// to use V8's code cache to speed up instantiation time
import "v8-compile-cache";
import * as Sentry from "@sentry/node";
import { version as release } from "../package.json";
import legacyAppEntry from "./legacy";
Expand Down
16 changes: 2 additions & 14 deletions lib/legacy/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#!/usr/bin/env node
// This is the main entry point for the ditto-cli command.
import { program } from "commander";
// to use V8's code cache to speed up instantiation time
import "v8-compile-cache";
import fs from "fs";
import path from "path";
import { init, needsTokenOrSource } from "./init/init";
import { pull } from "./pull";
import { quit } from "./utils/quit";
Expand All @@ -15,15 +11,7 @@ import { generateSuggestions } from "./generate-suggestions";
import processMetaOption from "./utils/processMetaOption";
import { importComponents } from "./importComponents";
import { showComponentFolders } from "./component-folders";

function getVersion(): string {
const packageJsonPath = path.join(__dirname, "../..", "package.json");
const packageJsonContent = fs.readFileSync(packageJsonPath, "utf8");
const packageJson = JSON.parse(packageJsonContent) as { version: string };
return packageJson.version;
}

const VERSION = getVersion();
import { version } from "../../package.json";

const CONFIG_FILE_RELIANT_COMMANDS = [
"pull",
Expand Down Expand Up @@ -186,7 +174,7 @@ const setupOptions = () => {
"-m, --meta <data...>",
"Include arbitrary data in requests to the Ditto API. Ex: -m githubActionRequest:true trigger:manual"
);
program.version(VERSION, "-v, --version", "Output the current version");
program.version(version, "-v, --version", "Output the current version");
};

const executeCommand = async (
Expand Down
16 changes: 2 additions & 14 deletions lib/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
#!/usr/bin/env node
// This is the main entry point for the ditto-cli command.
import { program } from "commander";
// to use V8's code cache to speed up instantiation time
import "v8-compile-cache";
import fs from "fs";
import path from "path";
import { pull } from "./commands/pull";
import { quit } from "./utils/quit";

function getVersion(): string {
const packageJsonPath = path.join(__dirname, "../../package.json");
const packageJsonContent = fs.readFileSync(packageJsonPath, "utf8");
const packageJson = JSON.parse(packageJsonContent) as { version: string };
return packageJson.version;
}

const VERSION = getVersion();
import { version } from "../../package.json";

const CONFIG_FILE_RELIANT_COMMANDS = [
"pull",
Expand Down Expand Up @@ -94,7 +82,7 @@ const setupCommands = () => {

const setupOptions = () => {
program.option("-l, --legacy", "Run in legacy mode");
program.version(VERSION, "-v, --version", "Output the current version");
program.version(version, "-v, --version", "Output the current version");
};

const executeCommand = async (
Expand Down
25 changes: 15 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
"version": "4.5.2",
"description": "Command Line Interface for Ditto (dittowords.com).",
"license": "MIT",
"main": "bin/index.js",
"main": "bin/ditto.js",
"scripts": {
"prepublishOnly": "ENV=production etsc && sentry-cli sourcemaps inject ./bin && npx sentry-cli sourcemaps upload ./bin --release=\"$(cat package.json | jq -r '.version')\"",
"prepublishOnly": "ENV=production node esbuild.mjs && sentry-cli sourcemaps inject ./bin && npx sentry-cli sourcemaps upload ./bin --release=\"$(cat package.json | jq -r '.version')\"",
"prepare": "husky install",
"start": "tsc --noEmit --excludeFiles './**/*.test.ts' && etsc && node bin/ditto.js",
"sync": "tsc --noEmit --excludeFiles './**/*.test.ts' && etsc && node bin/ditto.js pull",
"dev": "tsc --noEmit --excludeFiles './**/*.test.ts' && etsc --watch"
"start": "node esbuild.mjs && node bin/ditto.js",
"sync": "node esbuild.mjs && node bin/ditto.js pull"
},
"repository": {
"type": "git",
Expand All @@ -32,6 +31,14 @@
"bin": {
"ditto-cli": "bin/ditto.js"
},
"files": [
"bin",
"!bin/ditto.js.map",
"package.json",
"yarn.lock",
"README.md",
"LICENSE"
],
"devDependencies": {
"@babel/preset-env": "^7.20.2",
"@babel/preset-typescript": "^7.18.6",
Expand All @@ -43,8 +50,7 @@
"@types/node": "^18.0.0",
"babel-jest": "^29.3.1",
"dotenv": "^16.3.1",
"esbuild": "^0.19.2",
"esbuild-node-tsc": "^2.0.5",
"esbuild": "^0.25.2",
"husky": "^7.0.4",
"jest": "^29.3.1",
"lint-staged": "^11.2.4",
Expand All @@ -53,7 +59,7 @@
"source-map": "^0.7.3",
"tempy": "^0.6.0",
"ts-node": "^10.9.2",
"typescript": "^4.7.4"
"typescript": "^5.8.3"
},
"dependencies": {
"@babel/core": "^7.11.4",
Expand All @@ -72,8 +78,7 @@
"glob": "^9.3.4",
"js-yaml": "^4.1.0",
"memfs": "^4.7.7",
"ora": "^5.0.0",
"v8-compile-cache": "^2.1.1"
"ora": "^5.0.0"
},
"lint-staged": {
"src/**/*.{js,jsx,ts,tsx,css,json}": "prettier --write"
Expand Down
17 changes: 11 additions & 6 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
{
"extends": "@tsconfig/node16/tsconfig.json",
"compilerOptions": {
"allowJs": true,
"lib": ["es2019", "es2020.promise", "es2020.bigint", "es2020.string"],
"module": "commonjs",
"target": "es2019",

"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"moduleResolution": "node",
"allowJs": false,
"outDir": "bin",
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"strictNullChecks": true,
"sourceMap": true,
// Set `sourceRoot` to "/" to strip the build path prefix from
// generated source code references. This will improve issue grouping in Sentry.
"sourceRoot": "/",
"strict": true
"sourceRoot": "/"
},
"include": ["lib/**/*.ts"]
}
Loading