@stackbit/dev 0.0.9 → 0.0.13

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.
@@ -0,0 +1,3 @@
1
+ import yargs from 'yargs';
2
+ export declare function builder(yargs: yargs.Argv): void;
3
+ export declare function handler(argv: any): Promise<any>;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handler = exports.builder = void 0;
4
+ function builder(yargs) {
5
+ yargs
6
+ .option('port', {
7
+ alias: 'p',
8
+ description: 'port',
9
+ default: 3000
10
+ })
11
+ .options('host', {
12
+ alias: 'h',
13
+ description: 'hostname',
14
+ default: 'localhost'
15
+ })
16
+ .options('dir', {
17
+ alias: 'd',
18
+ description: 'root dir',
19
+ default: process.cwd()
20
+ })
21
+ .options('runnable-dir', {
22
+ description: 'runnable dir',
23
+ default: ''
24
+ })
25
+ .options('log-level', {
26
+ description: 'log level',
27
+ default: 'info'
28
+ })
29
+ .options('help', {});
30
+ }
31
+ exports.builder = builder;
32
+ async function handler(argv) {
33
+ if (argv['log-level']) {
34
+ process.env.LOG_LEVEL = argv['log-level'];
35
+ }
36
+ return require('./dev').start({
37
+ ssgPort: argv.port,
38
+ ssgHost: argv.host,
39
+ rootDir: argv.dir,
40
+ runnableDir: argv['runnable-dir']
41
+ });
42
+ }
43
+ exports.handler = handler;
44
+ //# sourceMappingURL=command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command.js","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":";;;AAEA,SAAgB,OAAO,CAAC,KAAiB;IACrC,KAAK;SACA,MAAM,CAAC,MAAM,EAAE;QACZ,KAAK,EAAE,GAAG;QACV,WAAW,EAAE,MAAM;QACnB,OAAO,EAAE,IAAI;KAChB,CAAC;SACD,OAAO,CAAC,MAAM,EAAE;QACb,KAAK,EAAE,GAAG;QACV,WAAW,EAAE,UAAU;QACvB,OAAO,EAAE,WAAW;KACvB,CAAC;SACD,OAAO,CAAC,KAAK,EAAE;QACZ,KAAK,EAAE,GAAG;QACV,WAAW,EAAE,UAAU;QACvB,OAAO,EAAE,OAAO,CAAC,GAAG,EAAE;KACzB,CAAC;SACD,OAAO,CAAC,cAAc,EAAE;QACrB,WAAW,EAAE,cAAc;QAC3B,OAAO,EAAE,EAAE;KACd,CAAC;SACD,OAAO,CAAC,WAAW,EAAE;QAClB,WAAW,EAAE,WAAW;QACxB,OAAO,EAAE,MAAM;KAClB,CAAC;SACD,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAC7B,CAAC;AA1BD,0BA0BC;AAEM,KAAK,UAAU,OAAO,CAAC,IAAS;IACnC,IAAI,IAAI,CAAC,WAAW,CAAC,EAAE;QACnB,OAAO,CAAC,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC;KAC7C;IACD,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC;QAC1B,OAAO,EAAE,IAAI,CAAC,IAAI;QAClB,OAAO,EAAE,IAAI,CAAC,IAAI;QAClB,OAAO,EAAE,IAAI,CAAC,GAAG;QACjB,WAAW,EAAE,IAAI,CAAC,cAAc,CAAC;KACpC,CAAC,CAAC;AACP,CAAC;AAVD,0BAUC"}
package/dist/index.js CHANGED
@@ -5,42 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  };
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  const yargs_1 = __importDefault(require("yargs"));
8
- (0, yargs_1.default)(process.argv.slice(2))
9
- .command('$0', 'stackbit-dev', (yargs) => yargs
10
- .option('port', {
11
- alias: 'p',
12
- description: 'port',
13
- default: 3000
14
- })
15
- .options('host', {
16
- alias: 'h',
17
- description: 'hostname',
18
- default: 'localhost'
19
- })
20
- .options('dir', {
21
- alias: 'd',
22
- description: 'root dir',
23
- default: process.cwd()
24
- })
25
- .options('runnable-dir', {
26
- description: 'runnable dir',
27
- default: ''
28
- })
29
- .options('log-level', {
30
- description: 'log level',
31
- default: 'info'
32
- })
33
- .options('help', {}), async (argv) => {
34
- if (argv['log-level']) {
35
- process.env.LOG_LEVEL = argv['log-level'];
36
- }
37
- return require('./dev').start({
38
- ssgPort: argv.port,
39
- ssgHost: argv.host,
40
- rootDir: argv.dir,
41
- runnableDir: argv['runnable-dir']
42
- });
43
- })
44
- .demandCommand()
45
- .parse();
8
+ const command_1 = require("./command");
9
+ (0, yargs_1.default)(process.argv.slice(2)).command('$0', 'stackbit-dev', command_1.builder, command_1.handler).demandCommand().parse();
46
10
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAEA,kDAA0B;AAE1B,IAAA,eAAK,EAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KACvB,OAAO,CACJ,IAAI,EACJ,cAAc,EACd,CAAC,KAAK,EAAE,EAAE,CACN,KAAK;KACA,MAAM,CAAC,MAAM,EAAE;IACZ,KAAK,EAAE,GAAG;IACV,WAAW,EAAE,MAAM;IACnB,OAAO,EAAE,IAAI;CAChB,CAAC;KACD,OAAO,CAAC,MAAM,EAAE;IACb,KAAK,EAAE,GAAG;IACV,WAAW,EAAE,UAAU;IACvB,OAAO,EAAE,WAAW;CACvB,CAAC;KACD,OAAO,CAAC,KAAK,EAAE;IACZ,KAAK,EAAE,GAAG;IACV,WAAW,EAAE,UAAU;IACvB,OAAO,EAAE,OAAO,CAAC,GAAG,EAAE;CACzB,CAAC;KACD,OAAO,CAAC,cAAc,EAAE;IACrB,WAAW,EAAE,cAAc;IAC3B,OAAO,EAAE,EAAE;CACd,CAAC;KACD,OAAO,CAAC,WAAW,EAAE;IAClB,WAAW,EAAE,WAAW;IACxB,OAAO,EAAE,MAAM;CAClB,CAAC;KACD,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,EAC5B,KAAK,EAAE,IAAI,EAAE,EAAE;IACX,IAAI,IAAI,CAAC,WAAW,CAAC,EAAE;QACnB,OAAO,CAAC,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC;KAC7C;IACD,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC;QAC1B,OAAO,EAAE,IAAI,CAAC,IAAI;QAClB,OAAO,EAAE,IAAI,CAAC,IAAI;QAClB,OAAO,EAAE,IAAI,CAAC,GAAG;QACjB,WAAW,EAAE,IAAI,CAAC,cAAc,CAAC;KACpC,CAAC,CAAC;AACP,CAAC,CACJ;KACA,aAAa,EAAE;KACf,KAAK,EAAE,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAEA,kDAA0B;AAC1B,uCAA6C;AAE7C,IAAA,eAAK,EAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,cAAc,EAAE,iBAAO,EAAE,iBAAO,CAAC,CAAC,aAAa,EAAE,CAAC,KAAK,EAAE,CAAC"}
@@ -5,15 +5,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.watchDir = void 0;
7
7
  const lodash_1 = __importDefault(require("lodash"));
8
+ const path_1 = __importDefault(require("path"));
8
9
  const chokidar_1 = __importDefault(require("chokidar"));
10
+ const logger_1 = __importDefault(require("./logger"));
9
11
  function watchDir(dir, onFileChange, throttleDelay = 1000) {
12
+ const fullDir = path_1.default.resolve(process.cwd(), dir);
13
+ logger_1.default.debug('Watch dir for changes: ' + fullDir);
10
14
  const watcher = chokidar_1.default.watch('.', {
11
- cwd: dir,
12
- ignored: (filePath) => filePath.includes('/.git/') ||
13
- filePath.includes('/.next/') ||
14
- filePath.includes('/.cache/') ||
15
- filePath.includes('/node_modules/') ||
16
- (filePath.includes('/.') && !filePath.includes('/.stackbit/')),
15
+ cwd: fullDir,
16
+ ignored: (filePath) => {
17
+ return (filePath.includes(`/.git/`) ||
18
+ filePath.includes(`/.next/`) ||
19
+ filePath.includes(`/.cache/`) ||
20
+ filePath.includes(`/node_modules`) ||
21
+ ((filePath.includes(`/.`) || filePath.startsWith(`.`)) && !(filePath.includes(`/.stackbit`) || filePath.startsWith(`.stackbit`))));
22
+ },
17
23
  persistent: true,
18
24
  ignoreInitial: true
19
25
  });
@@ -1 +1 @@
1
- {"version":3,"file":"file-watcher.js","sourceRoot":"","sources":["../../src/services/file-watcher.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AACvB,wDAAgC;AAEhC,SAAgB,QAAQ,CAAC,GAAW,EAAE,YAA2C,EAAE,aAAa,GAAG,IAAI;IACnG,MAAM,OAAO,GAAG,kBAAQ,CAAC,KAAK,CAAC,GAAG,EAAE;QAChC,GAAG,EAAE,GAAG;QACR,OAAO,EAAE,CAAC,QAAQ,EAAE,EAAE,CAClB,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC;YAC3B,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC;YAC5B,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC;YAC7B,QAAQ,CAAC,QAAQ,CAAC,gBAAgB,CAAC;YACnC,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;QAClE,UAAU,EAAE,IAAI;QAChB,aAAa,EAAE,IAAI;KACtB,CAAC,CAAC;IACH,IAAI,YAAY,GAAa,EAAE,CAAC;IAChC,MAAM,mBAAmB,GAAG,gBAAC,CAAC,QAAQ,CAAC,GAAG,EAAE;QACxC,IAAI,YAAY,CAAC,MAAM,EAAE;YACrB,YAAY,CAAC,YAAY,CAAC,CAAC;YAC3B,YAAY,GAAG,EAAE,CAAC;SACrB;IACL,CAAC,EAAE,aAAa,CAAC,CAAC;IAClB,M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,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,QAAQ,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CACpI,CAAC;QACN,CAAC;QACD,UAAU,EAAE,IAAI;QAChB,aAAa,EAAE,IAAI;KACtB,CAAC,CAAC;IACH,IAAI,YAAY,GAAa,EAAE,CAAC;IAChC,MAAM,mBAAmB,GAAG,gBAAC,CAAC,QAAQ,CAAC,GAAG,EAAE;QACxC,IAAI,YAAY,CAAC,MAAM,EAAE;YACrB,YAAY,CAAC,YAAY,CAAC,CAAC;YAC3B,YAAY,GAAG,EAAE,CAAC;SACrB;IACL,CAAC,EAAE,aAAa,CAAC,CAAC;IAClB,MAAM,gBAAgB,GAAG,CAAC,QAAgB,EAAE,EAAE;QAC1C,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;YAClC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SAC/B;QACD,mBAAmB,EAAE,CAAC;IAC1B,CAAC,CAAC;IACF,OAAO;SACF,EAAE,CAAC,KAAK,EAAE,gBAAgB,CAAC;SAC3B,EAAE,CAAC,QAAQ,EAAE,gBAAgB,CAAC;SAC9B,EAAE,CAAC,QAAQ,EAAE,gBAAgB,CAAC;SAC9B,EAAE,CAAC,QAAQ,EAAE,gBAAgB,CAAC;SAC9B,EAAE,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC;IAEvC,OAAO,OAAO,CAAC;AACnB,CAAC;AAtCD,4BAsCC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackbit/dev",
3
- "version": "0.0.9",
3
+ "version": "0.0.13",
4
4
  "description": "stackbit-dev",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -22,8 +22,8 @@
22
22
  "author": "Stackbit Inc.",
23
23
  "license": "MIT",
24
24
  "dependencies": {
25
- "@stackbit/cms-core": "^0.0.7",
26
- "@stackbit/dev-common": "^0.0.9",
25
+ "@stackbit/cms-core": "^0.0.8",
26
+ "@stackbit/dev-common": "^0.0.11",
27
27
  "@stackbit/sdk": "^0.2.22",
28
28
  "axios": "^0.25.0",
29
29
  "chalk": "^4.1.0",
@@ -54,5 +54,5 @@
54
54
  "ts-jest": "^27.1.3",
55
55
  "typescript": "^4.5.4"
56
56
  },
57
- "gitHead": "08dc9beff90a22d36c20b77923fc94c3808e01e4"
57
+ "gitHead": "8e4f212d57354e6c7f2d411f2fc3a19d614c4d8b"
58
58
  }
package/src/.DS_Store ADDED
Binary file
package/src/command.ts ADDED
@@ -0,0 +1,41 @@
1
+ import yargs from 'yargs';
2
+
3
+ export function builder(yargs: yargs.Argv) {
4
+ yargs
5
+ .option('port', {
6
+ alias: 'p',
7
+ description: 'port',
8
+ default: 3000
9
+ })
10
+ .options('host', {
11
+ alias: 'h',
12
+ description: 'hostname',
13
+ default: 'localhost'
14
+ })
15
+ .options('dir', {
16
+ alias: 'd',
17
+ description: 'root dir',
18
+ default: process.cwd()
19
+ })
20
+ .options('runnable-dir', {
21
+ description: 'runnable dir',
22
+ default: ''
23
+ })
24
+ .options('log-level', {
25
+ description: 'log level',
26
+ default: 'info'
27
+ })
28
+ .options('help', {});
29
+ }
30
+
31
+ export async function handler(argv: any) {
32
+ if (argv['log-level']) {
33
+ process.env.LOG_LEVEL = argv['log-level'];
34
+ }
35
+ return require('./dev').start({
36
+ ssgPort: argv.port,
37
+ ssgHost: argv.host,
38
+ rootDir: argv.dir,
39
+ runnableDir: argv['runnable-dir']
40
+ });
41
+ }
package/src/index.ts CHANGED
@@ -1,48 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import yargs from 'yargs';
4
+ import { builder, handler } from './command';
4
5
 
5
- yargs(process.argv.slice(2))
6
- .command(
7
- '$0',
8
- 'stackbit-dev',
9
- (yargs) =>
10
- yargs
11
- .option('port', {
12
- alias: 'p',
13
- description: 'port',
14
- default: 3000
15
- })
16
- .options('host', {
17
- alias: 'h',
18
- description: 'hostname',
19
- default: 'localhost'
20
- })
21
- .options('dir', {
22
- alias: 'd',
23
- description: 'root dir',
24
- default: process.cwd()
25
- })
26
- .options('runnable-dir', {
27
- description: 'runnable dir',
28
- default: ''
29
- })
30
- .options('log-level', {
31
- description: 'log level',
32
- default: 'info'
33
- })
34
- .options('help', {}),
35
- async (argv) => {
36
- if (argv['log-level']) {
37
- process.env.LOG_LEVEL = argv['log-level'];
38
- }
39
- return require('./dev').start({
40
- ssgPort: argv.port,
41
- ssgHost: argv.host,
42
- rootDir: argv.dir,
43
- runnableDir: argv['runnable-dir']
44
- });
45
- }
46
- )
47
- .demandCommand()
48
- .parse();
6
+ yargs(process.argv.slice(2)).command('$0', 'stackbit-dev', builder, handler).demandCommand().parse();
@@ -1,15 +1,22 @@
1
1
  import _ from 'lodash';
2
+ import path from 'path';
2
3
  import chokidar from 'chokidar';
4
+ import logger from './logger';
3
5
 
4
6
  export function watchDir(dir: string, onFileChange: (filePaths: string[]) => void, throttleDelay = 1000) {
7
+ const fullDir = path.resolve(process.cwd(), dir);
8
+ logger.debug('Watch dir for changes: ' + fullDir);
5
9
  const watcher = chokidar.watch('.', {
6
- cwd: dir,
7
- ignored: (filePath) =>
8
- filePath.includes('/.git/') ||
9
- filePath.includes('/.next/') ||
10
- filePath.includes('/.cache/') ||
11
- filePath.includes('/node_modules/') ||
12
- (filePath.includes('/.') && !filePath.includes('/.stackbit/')),
10
+ cwd: fullDir,
11
+ ignored: (filePath) => {
12
+ return (
13
+ filePath.includes(`/.git/`) ||
14
+ filePath.includes(`/.next/`) ||
15
+ filePath.includes(`/.cache/`) ||
16
+ filePath.includes(`/node_modules`) ||
17
+ ((filePath.includes(`/.`) || filePath.startsWith(`.`)) && !(filePath.includes(`/.stackbit`) || filePath.startsWith(`.stackbit`)))
18
+ );
19
+ },
13
20
  persistent: true,
14
21
  ignoreInitial: true
15
22
  });