protagonist-jsnote 0.3.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.claude/settings.local.json +7 -0
- package/dist/commands/serve.js +25 -0
- package/dist/commands/serve.js.map +1 -0
- package/dist/index.js +481 -0
- package/dist/index.js.map +1 -0
- package/package.json +32 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import { serve } from '@protagonist-jsnote/api';
|
|
4
|
+
const isProduction = process.env.NODE_ENV === 'production';
|
|
5
|
+
export const serveCommand = new Command()
|
|
6
|
+
.command('serve [filename]')
|
|
7
|
+
.description('Open a file for editing')
|
|
8
|
+
.option('-p, --port <number>', 'port to run server on', '4005')
|
|
9
|
+
.action((filename = 'notebook.json', options) => {
|
|
10
|
+
const dir = path.join(process.cwd(), path.dirname(filename));
|
|
11
|
+
const isLocalApiError = (err) => {
|
|
12
|
+
return err != null && typeof err.code === "string";
|
|
13
|
+
};
|
|
14
|
+
serve(parseInt(options.port), path.basename(filename), dir, !isProduction)
|
|
15
|
+
.catch((err) => {
|
|
16
|
+
if (isLocalApiError(err) && err.code === 'EADDRINUSE') {
|
|
17
|
+
console.error('Port in use. Try running on a different port');
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
else if (err instanceof Error) {
|
|
21
|
+
throw err;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=serve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serve.js","sourceRoot":"","sources":["../../src/commands/serve.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAOhD,MAAM,YAAY,GAAG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