-
Notifications
You must be signed in to change notification settings - Fork 678
feat(cli-hooks): add default app and manifest watch config #2480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f80594a
118788e
f6b85d9
e6cbbfb
bfa23c8
d69734c
14899a9
cc8e5b7
2a849b9
5fcd109
a2f0e82
10b695b
7c7927d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| --- | ||
| "@slack/cli-hooks": minor | ||
| --- | ||
|
|
||
| feat(cli-hooks): add default app and manifest watch config | ||
|
|
||
| This package now provides default watch configurations for automatic file watching during [`slack run`](https://docs.slack.dev/tools/slack-cli/reference/commands/slack_platform_run). The CLI will restart your app server when source files change and reinstall your app when the manifest changes. | ||
|
|
||
| **Requirements:** These features require Slack CLI v3.12.0+ with [file watching support](https://github.com/slackapi/slack-cli/pull/310). | ||
|
|
||
| ### Default Configuration | ||
|
|
||
| The following watch settings are provided automatically when using this package: | ||
|
|
||
| ```json | ||
| { | ||
| "config": { | ||
| "watch": { | ||
| "app": { | ||
| "filter-regex": "\\.js$", | ||
| "paths": ["."] | ||
| }, | ||
| "manifest": { | ||
| "paths": ["manifest.json"] | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| - **app**: Watches for JavaScript file changes to restart the app server | ||
| - **manifest**: Watches the manifest file for changes to reinstall the app | ||
|
|
||
| **Note:** Manifest watching requires a local manifest source in your `.slack/config.json` file. Remote manifests will not be updated on file changes. | ||
|
|
||
| ```json | ||
| { | ||
| "manifest": { | ||
| "source": "local" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### Custom Configurations | ||
|
|
||
| You can override these defaults in your `.slack/hooks.json` file to reduce the paths searched or change the file patterns. Read [Watch Configurations](https://docs.slack.dev/tools/slack-cli/reference/hooks/#watch-configurations) for more options. | ||
|
|
||
| ### TypeScript Development | ||
|
|
||
| TypeScript developers should run `tsc --watch` in a separate terminal during development. This compiles `.ts` files to `.js` on changes, and the default watch configuration will detect changes to the compiled `dist/*.js` files and restart the app server. This approach works best with the default settings. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,9 +32,23 @@ if (fs.realpathSync(process.argv[1]) === fileURLToPath(import.meta.url)) { | |
| */ | ||
|
|
||
| /** | ||
| * Information about the files to watch for specific changes. | ||
| * Information about file changes for CLI actions. | ||
| * @typedef SDKConfigWatch | ||
| * @property {string} filter-regex - Regex pattern for finding filtered files. | ||
| * @property {AppConfigWatch} app - Watch config for server restarts. | ||
| * @property {ManifestConfigWatch} manifest - Watch config for app reinstalls. | ||
| */ | ||
|
|
||
| /** | ||
| * Information about the app files to watch for server restarts. | ||
| * @typedef AppConfigWatch | ||
| * @property {string} [filter-regex] - Regex pattern for finding filtered files. | ||
| * @property {string[]} paths - Specific locations to begin searching for files. | ||
| */ | ||
|
|
||
| /** | ||
| * Information about the manifest files to watch for app reinstalls. | ||
| * @typedef ManifestConfigWatch | ||
| * @property {string} [filter-regex] - Regex pattern for finding filtered files. | ||
| * @property {string[]} paths - Specific locations to begin searching for files. | ||
| */ | ||
|
|
||
|
|
@@ -52,8 +66,13 @@ export default function getHooks() { | |
| }, | ||
| config: { | ||
| watch: { | ||
| 'filter-regex': '^manifest\\.json$', | ||
| paths: ['.'], | ||
| app: { | ||
| 'filter-regex': '\\.js$', | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Non-blocker. Not sure if we want to include, this but we could ignore
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mwbrooks Our current CLI implementations don't support "not" paths AFAICT. We might want to follow up with this, since changes to the |
||
| paths: ['.'], | ||
| }, | ||
| manifest: { | ||
| paths: ['manifest.json'], | ||
| }, | ||
| }, | ||
| 'protocol-version': SUPPORTED_NAMED_PROTOCOLS, | ||
| 'sdk-managed-connection-enabled': true, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,4 +21,19 @@ describe('get-hooks implementation', async () => { | |
| const { config } = getHooks(); | ||
| assert(config['sdk-managed-connection-enabled']); | ||
| }); | ||
|
|
||
| it('should return watch config for app files', async () => { | ||
| const { config } = getHooks(); | ||
| assert(config.watch); | ||
| assert(config.watch.app); | ||
| assert.equal(config.watch.app['filter-regex'], '\\.js$'); | ||
| assert.deepEqual(config.watch.app.paths, ['.']); | ||
| }); | ||
|
|
||
| it('should return watch config for manifest files', async () => { | ||
| const { config } = getHooks(); | ||
| assert(config.watch); | ||
| assert(config.watch.manifest); | ||
| assert.deepEqual(config.watch.manifest.paths, ['manifest.json']); | ||
|
Comment on lines
+25
to
+37
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ty for good tests 👾! |
||
| }); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤩