@inlang/paraglide-js
Advanced tools
Comparing version 1.0.0-prerelease.2 to 1.0.0-prerelease.3
@@ -7,3 +7,3 @@ import { loadProject } from "@inlang/sdk"; | ||
import { Command } from "commander"; | ||
import { paraglideDirectory } from "../main.js"; | ||
import { paraglideDirectory } from "../state.js"; | ||
import dedent from "dedent"; | ||
@@ -10,0 +10,0 @@ export const compileCommand = new Command() |
import { Command } from "commander"; | ||
/** | ||
* The absolute path to the paraglide directory. | ||
* | ||
* slices a path | ||
* from '/Users/samuel/example/repository/node_modules/paraglide-js/dist/cli/main.js' | ||
* to '/Users/samuel/example/repository/node_modules/paraglide-js' | ||
*/ | ||
export declare const paraglideDirectory: string; | ||
export declare const cli: Command; | ||
//# sourceMappingURL=main.d.ts.map |
import consola from "consola"; | ||
import dedent from "dedent"; | ||
import { fileURLToPath } from "node:url"; | ||
import { Command } from "commander"; | ||
import { compileCommand } from "./commands/compile.js"; | ||
/** | ||
* The path this file is executed from. | ||
* | ||
* Usually something like '/Users/samuel/example/repository/node_modules/paraglide-js/dist/cli/main.js' | ||
*/ | ||
const metaUrlPath = fileURLToPath(import.meta.url); | ||
/** | ||
* The absolute path to the paraglide directory. | ||
* | ||
* slices a path | ||
* from '/Users/samuel/example/repository/node_modules/paraglide-js/dist/cli/main.js' | ||
* to '/Users/samuel/example/repository/node_modules/paraglide-js' | ||
*/ | ||
export const paraglideDirectory = metaUrlPath.slice(0, metaUrlPath.indexOf("/dist/")); | ||
import { paraglideDirectory } from "./state.js"; | ||
export const cli = new Command() | ||
.name("paraglide-js") | ||
.addCommand(compileCommand) | ||
.hook("preAction", () => { | ||
.action(() => { | ||
// ------------------- VALIDATE IF RUNNING FROM CORRECT FOLDER ------------------- | ||
// the CLI expects to be running from the dist folder of the specific paraglide package | ||
// to compile the output in the correct directory | ||
if (metaUrlPath.includes(`paraglide-js/dist/`) === false) { | ||
if (paraglideDirectory.endsWith(`paraglide-js`) === false) { | ||
consola.error(dedent ` | ||
The CLI is not running from the dist folder. | ||
The CLI is not running from a paraglide-js directory. | ||
@@ -35,7 +21,9 @@ This is likely an internal bug. Please file an issue at https://github.com/inlang/monorepo/issues. | ||
- metaUrlPath: ${metaUrlPath} | ||
- paraglideDirectory: ${paraglideDirectory} | ||
`); | ||
process.exit(1); | ||
return process.exit(1); | ||
} | ||
// show the help because no command is specified | ||
return cli.help(); | ||
}); | ||
cli.showHelpAfterError(true); |
{ | ||
"name": "@inlang/paraglide-js", | ||
"type": "module", | ||
"version": "1.0.0-prerelease.2", | ||
"version": "1.0.0-prerelease.3", | ||
"license": "Apache-2.0", | ||
@@ -6,0 +6,0 @@ "publishConfig": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
47722
51
949