-
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.
- Loading branch information
Showing
15 changed files
with
299 additions
and
223 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
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,77 @@ | ||
# Extend Rowen | ||
|
||
Rowen can be extend by your own, supports custom events and contexts. | ||
|
||
## Custom events example | ||
|
||
```ts | ||
// rowen.config.ts | ||
import { externalTask } from "./external-task.ts";} | ||
|
||
export default rowenConfig(() => { | ||
return { | ||
// ...options, | ||
flows: async rowen => { | ||
rowen.on.beforeFetch(async ($) => { | ||
// emit events | ||
await rowen.emit("startDeploy", $, arg2); | ||
|
||
const exteranlCtx = $.ctx(externalTask.ctx); | ||
console.log(externalCtx); // => { status: "sokosoko fine" } | ||
}); | ||
|
||
rowen.on.startDeploy(($, arg2) => { | ||
// startDeploy events | ||
}); | ||
} | ||
} | ||
}) | ||
|
||
// | ||
|
||
declare module "@hanakla/rowen" { | ||
export interface ExtendedRowenEvents { | ||
startDeploy: [PilotLight, Arg2]; | ||
} | ||
``` | ||
## Custom context example | ||
```ts | ||
// externalTask.ts | ||
|
||
const ctx = Symbol(); | ||
export const externalTask = { | ||
// Expose context key as unique symbol | ||
ctx: ctx as typeof ctx, | ||
beforeFetch: ($: PilotLight, arg2: Arg2) => { | ||
$.ctx.set(externalTask.ctx, { status: "sokosoko fine" }); | ||
}, | ||
}; | ||
|
||
declare module "@hanakla/rowen" { | ||
export interface ExtendedRowenContexts { | ||
[externalTask.ctx]: { status: string }; | ||
} | ||
} | ||
``` | ||
```ts | ||
// rowen.config.ts | ||
import { externalTask } from "./externalTask.ts"; | ||
|
||
export default rowenConfig(() => { | ||
return { | ||
// ...options, | ||
flows: async (rowen) => { | ||
rowen.on.beforeFetch(externalTask.beforeFetch); | ||
|
||
rowen.on.beforeFetch(async ($) => { | ||
// Get context by `externalTask.ctx` | ||
const exteranlCtx = $.ctx(externalTask.ctx); | ||
console.log(externalCtx); // => { status: "sokosoko fine" } | ||
}); | ||
}, | ||
}; | ||
}); | ||
``` |
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,17 @@ | ||
### How to get deployment context / options | ||
|
||
If deploy context/status you want, it can be get via `$.ctx` method. | ||
|
||
```ts | ||
rowenConfig(async () => { | ||
return { | ||
// ...options, | ||
flows: (rowen) => { | ||
rowen.on.beforeFetch(async ($) => { | ||
const context = $.ctx(Rowen.ctx); | ||
const releaseContext = $.ctx(presets.releases.ctx); | ||
}); | ||
}, | ||
}; | ||
}); | ||
``` |
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 @@ | ||
# Rowen docs | ||
|
||
- [How to get deployment context / options](./get-contexts.md) | ||
- [Presets](./presets.md) | ||
- [Scripting to remotes](./scripting-to-remotes.md) | ||
- [Extending rowen](./extending.md) |
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,52 @@ | ||
# Presets | ||
|
||
## `presets.releases` | ||
|
||
Manage releases presets, likes `shipit-deploy`. | ||
|
||
### Usage | ||
|
||
```ts | ||
// rowen.config.ts | ||
import { presets } from "rowen"; | ||
|
||
export default rowenConfig(() => { | ||
return { | ||
// ... options | ||
flows: async (rowen) => { | ||
rowen.on.caughtError(releases.caughtError()); | ||
|
||
rowen.on.beforeFetch( | ||
releases.beforeFetch({ | ||
sourceDir: "./", | ||
keepReleases: 2, | ||
}) | ||
); | ||
|
||
rowen.on.buildStep(async ($) => { | ||
// building scripts write your own | ||
}); | ||
|
||
rowen.on.syncStep(releases.syncStep()); | ||
}, | ||
}; | ||
}); | ||
``` | ||
|
||
### Options on `releases.beforeFetch` | ||
|
||
- _`sourceDir: string`_ Default `"."`. Copying directory path on local | ||
- _`keepReleases: number`_ Default `10`. Number of past releases to keep on remote | ||
- _`releasesPath: string`_ Default `"./releases"`. Directory path where all releases are located | ||
- _`enableShared: boolean`_ Default `true`. If enabled, creates a `shared` directory to place files shared between releases | ||
|
||
### Remote directory structure | ||
|
||
`presets.releases` makes directory structure likes below on remotes. | ||
|
||
``` | ||
- deployToDir/ | ||
- releases/ | ||
- [releaseId] | ||
- shared/ | ||
``` |
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,9 @@ | ||
# Scripting to remotes | ||
|
||
```ts | ||
import Rowen from "rowen"; | ||
|
||
Rowen.script({ env: "staging", verbose: true }, ($) => { | ||
$.remote`hostname`; | ||
}); | ||
``` |
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
Oops, something went wrong.