-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from primno/dev
Open environment url in start command
- Loading branch information
Showing
12 changed files
with
91 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@primno/cli": minor | ||
--- | ||
|
||
Opens the environment url when the start command is executed. | ||
Added "--no-open" option in the start command. If this option is set, the environment will not be opened in the browser. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,21 @@ | ||
import { Command } from "commander"; | ||
import { Workspace } from "../core/workspace"; | ||
|
||
async function startAction() { | ||
interface Options { | ||
open: boolean; | ||
} | ||
|
||
async function startAction(options: Options) { | ||
if (!Workspace.isWorkspace(".")) { | ||
console.error("This action must be run in a primno project directory"); | ||
return; | ||
} | ||
|
||
const currentWs = new Workspace("."); | ||
await currentWs.start({}); | ||
await currentWs.start({ openInBrowser: options.open }); | ||
}; | ||
|
||
export const startCommand = new Command("start") | ||
.description("deploy primno in local development mode and run a web server that watches the entry points files") | ||
.option("--no-open", "do not open the browser", false) | ||
.action(startAction); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import path from "path"; | ||
import { RollupError, RollupWarning } from "rollup"; | ||
|
||
export function buildMessage(source: RollupWarning | RollupError): string { | ||
if (source.loc?.file) { | ||
const filePath = path.relative(".", source.loc.file); | ||
return `${source.message} from "${filePath}":${source.loc.line}:${source.loc.column}`; | ||
} | ||
else { | ||
return `${source.message}`; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,10 @@ | ||
import path from "path"; | ||
import { WarningHandler } from "rollup"; | ||
import { ResultBuilder } from "../../../task"; | ||
import { buildMessage } from "./message-builder"; | ||
|
||
export function onWarnWrapper(resultBuilder: ResultBuilder): WarningHandler { | ||
return (warning) => { | ||
if (warning.loc?.file) { | ||
const filePath = path.relative(".", warning.loc.file); | ||
resultBuilder.addWarning(`${warning.message} at ${filePath} [${warning.loc.line}, ${warning.loc.column}]`); | ||
} | ||
else { | ||
resultBuilder.addWarning(`${warning.message}`); | ||
} | ||
const message = buildMessage(warning); | ||
resultBuilder.addWarning(message); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters