-
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 #79 from vivid-planet/id-for-script
feat: every script is now accessible through an dedicated numeric id
- Loading branch information
Showing
13 changed files
with
71 additions
and
51 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,5 @@ | ||
--- | ||
"@comet/dev-process-manager": minor | ||
--- | ||
|
||
every script is now accessible through an dedicated numeric id |
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,6 +1,7 @@ | ||
import { LogsCommandOptions } from "../daemon-command/logs.daemon-command"; | ||
import { connect } from "./connect"; | ||
|
||
export const logs = async (names: string[]): Promise<void> => { | ||
export const logs = async (options: LogsCommandOptions): Promise<void> => { | ||
const client = await connect(); | ||
client.write(`logs ${JSON.stringify(names)}`); | ||
client.write(`logs ${JSON.stringify(options)}`); | ||
}; |
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,6 +1,7 @@ | ||
import { StopCommandOptions } from "../daemon-command/stop.daemon-command"; | ||
import { connect } from "./connect"; | ||
|
||
export const stop = async (names: string[]): Promise<void> => { | ||
export const stop = async (options: StopCommandOptions): Promise<void> => { | ||
const client = await connect(); | ||
client.write(`stop ${JSON.stringify(names)}`); | ||
client.write(`stop ${JSON.stringify(options)}`); | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,25 @@ | ||
import { Daemon } from "../commands/start-daemon.command"; | ||
import { Script } from "./script"; | ||
|
||
export function scriptsMatchingPattern(daemon: Daemon, names: string[]): Script[] { | ||
if (names.length == 0 || names.includes("all")) { | ||
// all | ||
return daemon.scripts; | ||
} | ||
export interface ScriptsMatchingPatternOptions { | ||
patterns: string[]; | ||
} | ||
|
||
export function scriptsMatchingPattern(daemon: Daemon, { patterns }: ScriptsMatchingPatternOptions): Script[] { | ||
const uniquePatterns = [...new Set(patterns.map((pattern) => pattern.split(",")).flat())]; | ||
const ids = uniquePatterns.filter((pattern) => pattern && !isNaN(+pattern)).map(Number) || []; | ||
const names = uniquePatterns.filter((pattern) => pattern && isNaN(+pattern)) || []; | ||
|
||
return daemon.scripts.filter((script) => { | ||
return names.some((name) => { | ||
if (name[0] === "@") { | ||
if (script.groups.includes(name.substring(1))) return true; | ||
} else { | ||
if (script.name == name) return true; | ||
} | ||
return false; | ||
if (ids.length === 0 && names.length === 0) return true; | ||
|
||
const idExists = ids.some((id) => script.id === id); | ||
const nameExists = names.some((name) => { | ||
if (name === "all") return true; | ||
if (name[0] === "@" && script.groups.includes(name[0])) return true; | ||
return script.name === name; | ||
}); | ||
|
||
return idExists || nameExists; | ||
}); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export interface ScriptDefinition { | ||
id: number; | ||
name: string; | ||
script: string; | ||
group?: string | string[]; | ||
|