Move the `appsmithctl` code to RTS. RTS' own build system will build `appsmithctl` as well. We're adding two command scripts, `ctl` and `appsmithctl` to `/opt/bin`, which will be the entrypoints for this. The `appsmithctl` is now just an alias to the much shorter and non-redundancy-inducing `ctl`. We aren't migrating to TypeScript in this PR so we're ignoring the new `ctl` folder in both `tsconfig.json` and `.eslintrc`. That's temporary, the next PR will fix that. ## Automation /test sanity ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/11930931528> > Commit: 90b5f97b801ac8d4b4b0126d85edff3dccc050bd > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11930931528&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Sanity` > Spec: > <hr>Wed, 20 Nov 2024 10:36:02 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes - **New Features** - Introduced the `appsmithctl` command for easier command execution. - Updated build process to include additional entry points. - **Bug Fixes** - Streamlined Docker build process, enhancing efficiency and reducing complexity. - **Documentation** - Added a new section in the README for `appsmithctl` command description. - **Chores** - Updated dependencies in `package.json`. - Removed obsolete files and workflows to simplify project structure. - **Style** - Added a new ESLint configuration for specific project needs. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
92 lines
2.4 KiB
JavaScript
92 lines
2.4 KiB
JavaScript
const { dependencies: packageDeps } = require("./package.json");
|
|
const esbuild = require("esbuild");
|
|
const fs = require("fs").promises;
|
|
|
|
// List of external workflow packages (EE only)
|
|
const externalWorkflowPackages = [];
|
|
|
|
async function ensureDirectoryExistence(dirname) {
|
|
try {
|
|
await fs.mkdir(dirname, { recursive: true });
|
|
} catch (err) {
|
|
if (err.code !== "EEXIST") {
|
|
throw err;
|
|
}
|
|
}
|
|
}
|
|
|
|
async function createFile(dir, filename, content) {
|
|
try {
|
|
await ensureDirectoryExistence(dir);
|
|
const filePath = `${dir}/${filename}`;
|
|
await fs.writeFile(filePath, content);
|
|
} catch (err) {
|
|
console.error("Error writing file:", err);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Get dependencies for workflow packages
|
|
* @returns {Object} workflow dependencies
|
|
*/
|
|
const getWorkflowDependencies = () => {
|
|
if (externalWorkflowPackages.length === 0) {
|
|
return {};
|
|
}
|
|
return Object.entries(packageDeps).reduce((acc, [key, value]) => {
|
|
if (externalWorkflowPackages.includes(key)) {
|
|
acc[key] = value;
|
|
}
|
|
return acc;
|
|
}, {});
|
|
};
|
|
|
|
const bundle = async () => {
|
|
return esbuild
|
|
.build({
|
|
entryPoints: ["src/server.ts", "src/ctl/index.js"],
|
|
bundle: true,
|
|
sourcemap: true,
|
|
platform: "node",
|
|
external: [...externalWorkflowPackages, "dtrace-provider"],
|
|
loader: {
|
|
".ts": "ts",
|
|
},
|
|
tsconfig: "tsconfig.json",
|
|
outdir: "dist/bundle",
|
|
target: "node" + process.versions.node,
|
|
minify: true,
|
|
keepNames: true,
|
|
})
|
|
.catch(() => process.exit(1));
|
|
};
|
|
|
|
(async () => {
|
|
if (externalWorkflowPackages.length > 0) {
|
|
// Create package.json for bundle, this is needed to install workflow dependencies
|
|
// in the bundle directory. This is needed for EE only. This is done to support the
|
|
// packages for our workflow provider which requires dynamic imports. ESBuild does
|
|
// not support dynamic imports for external packages hence we need to bundle them
|
|
// together with the workflow provider.
|
|
const bundlePackagejson = {
|
|
name: "rts-bundle",
|
|
version: "1.0.0",
|
|
description: "",
|
|
main: "bundle/server.js",
|
|
dependencies: getWorkflowDependencies(),
|
|
};
|
|
|
|
createFile(
|
|
"dist",
|
|
"package.json",
|
|
JSON.stringify(bundlePackagejson, null, 2),
|
|
);
|
|
|
|
console.log("Bundle package.json created successfully");
|
|
}
|
|
|
|
await bundle();
|
|
|
|
console.log("Bundle created successfully");
|
|
})();
|