@stackbit/dev 0.0.3
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/assets/loading-page.html +54 -0
- package/dist/config.d.ts +7 -0
- package/dist/config.js +9 -0
- package/dist/config.js.map +1 -0
- package/dist/consts.d.ts +12 -0
- package/dist/consts.js +47 -0
- package/dist/consts.js.map +1 -0
- package/dist/dev.d.ts +6 -0
- package/dist/dev.js +57 -0
- package/dist/dev.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +46 -0
- package/dist/index.js.map +1 -0
- package/dist/runner/index.d.ts +38 -0
- package/dist/runner/index.js +141 -0
- package/dist/runner/index.js.map +1 -0
- package/dist/runner/ssg.d.ts +9 -0
- package/dist/runner/ssg.js +15 -0
- package/dist/runner/ssg.js.map +1 -0
- package/dist/server/index.d.ts +7 -0
- package/dist/server/index.js +51 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/proxy.d.ts +2 -0
- package/dist/server/proxy.js +81 -0
- package/dist/server/proxy.js.map +1 -0
- package/dist/server/routes.d.ts +3 -0
- package/dist/server/routes.js +190 -0
- package/dist/server/routes.js.map +1 -0
- package/dist/services/api.d.ts +4 -0
- package/dist/services/api.js +15 -0
- package/dist/services/api.js.map +1 -0
- package/dist/services/file-watcher.d.ts +2 -0
- package/dist/services/file-watcher.js +42 -0
- package/dist/services/file-watcher.js.map +1 -0
- package/dist/services/logger.d.ts +6 -0
- package/dist/services/logger.js +35 -0
- package/dist/services/logger.js.map +1 -0
- package/dist/services/ngrok.d.ts +1 -0
- package/dist/services/ngrok.js +18 -0
- package/dist/services/ngrok.js.map +1 -0
- package/dist/services/user-config.d.ts +1 -0
- package/dist/services/user-config.js +16 -0
- package/dist/services/user-config.js.map +1 -0
- package/package.json +59 -0
- package/src/assets/loading-page.html +54 -0
- package/src/config.ts +6 -0
- package/src/consts.ts +44 -0
- package/src/dev.ts +65 -0
- package/src/index.ts +48 -0
- package/src/runner/index.ts +162 -0
- package/src/runner/ssg.ts +10 -0
- package/src/server/index.ts +65 -0
- package/src/server/proxy.ts +85 -0
- package/src/server/routes.ts +186 -0
- package/src/services/api.ts +10 -0
- package/src/services/file-watcher.ts +37 -0
- package/src/services/logger.ts +34 -0
- package/src/services/ngrok.ts +11 -0
- package/src/services/user-config.ts +14 -0
- package/src/types/http-proxy-middleware.d.ts +3 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxy.js","sourceRoot":"","sources":["../../src/server/proxy.ts"],"names":[],"mappings":";;;;;AAAA,oDAAuB;AACvB,gDAAwB;AACxB,sDAA2C;AAC3C,kFAA0C;AAC1C,gEAAwC;AACxC,uDAA+B;AAC/B,6EAAwH;AACxH,iEAA0E;AAC1E,uDAA+B;AAG/B,SAAwB,eAAe,CAAC,OAAe,EAAE,OAAe,EAAE,MAAc;;IACpF,MAAM,MAAM,GAAG,iBAAO,CAAC,MAAM,EAAE,CAAC;IAEhC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QAC1B,gBAAC,CAAC,KAAK,CAAC,GAAG,EAAE,2BAA2B,CAAC,CAAC;QAC1C,MAAM,UAAU,GAAG,gBAAC,CAAC,GAAG,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;QAC5C,MAAM,WAAW,GAAG,gBAAC,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,WAAW,EAAE,KAAK,mBAAmB,CAAC,CAAC;QAChH,IAAI,WAAW,GAAG,CAAC,CAAC,EAAE;YAClB,kCAAkC;YAClC,UAAU,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;SACrC;QACD,IAAI,EAAE,CAAC;IACX,CAAC,CAAC,CAAC;IAEH,MAAM,cAAc,GAAG,UAAU,OAAO,IAAI,OAAO,EAAE,CAAC;IAEtD,MAAM,iBAAiB,GAAG,CAAC,GA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@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
7
|
+
const body_parser_1 = __importDefault(require("body-parser"));
|
|
8
|
+
const logger_1 = __importDefault(require("../services/logger"));
|
|
9
|
+
const response_errors_1 = require("@stackbit/dev-common/dist/services/response-errors");
|
|
10
|
+
function routes(router, runner) {
|
|
11
|
+
router.get('/_health', (req, res) => {
|
|
12
|
+
return res.status(200).json({ status: 'ok' });
|
|
13
|
+
});
|
|
14
|
+
router.post('/_objects', [body_parser_1.default.json({ limit: '500kb' })], (req, res, next) => {
|
|
15
|
+
const { objectIds } = req.body;
|
|
16
|
+
return runner
|
|
17
|
+
.getObjects(objectIds)
|
|
18
|
+
.then((result) => {
|
|
19
|
+
res.json(result);
|
|
20
|
+
})
|
|
21
|
+
.catch((err) => {
|
|
22
|
+
logger_1.default.error('Error fetching data objects');
|
|
23
|
+
logger_1.default.debug('error getting fieldData from runner', { error: err.message || err });
|
|
24
|
+
if (lodash_1.default.has(err, 'stack')) {
|
|
25
|
+
logger_1.default.debug('error getting fieldData from runner, error.stack: ' + err.stack);
|
|
26
|
+
}
|
|
27
|
+
res.status(500).send('Error');
|
|
28
|
+
next(err);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
router.post('/_objectsWithAnnotations', [body_parser_1.default.json({ limit: '500kb' })], (req, res, next) => {
|
|
32
|
+
const { annotationTree, clientAnnotationErrors } = req.body;
|
|
33
|
+
return runner
|
|
34
|
+
.getObjectsWithAnnotations(annotationTree, clientAnnotationErrors)
|
|
35
|
+
.then((result) => {
|
|
36
|
+
res.json(result);
|
|
37
|
+
})
|
|
38
|
+
.catch((err) => {
|
|
39
|
+
logger_1.default.error('Error fetching data objects with annotations');
|
|
40
|
+
logger_1.default.debug('error getting fieldData with annotations from runner', { error: err.message || err });
|
|
41
|
+
if (lodash_1.default.has(err, 'stack')) {
|
|
42
|
+
logger_1.default.debug('error getting fieldData with annotations from runner, error.stack: ' + err.stack);
|
|
43
|
+
}
|
|
44
|
+
res.status(500).send('Error');
|
|
45
|
+
next(err);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
router.get('/_collections', (req, res, next) => {
|
|
49
|
+
return runner
|
|
50
|
+
.getCollections()
|
|
51
|
+
.then((result) => {
|
|
52
|
+
res.json(result);
|
|
53
|
+
})
|
|
54
|
+
.catch((err) => {
|
|
55
|
+
logger_1.default.error('Error fetching collections');
|
|
56
|
+
logger_1.default.debug('error getting collections from runner', { error: err.message || err });
|
|
57
|
+
if (lodash_1.default.has(err, 'stack')) {
|
|
58
|
+
logger_1.default.debug('error getting collections from runner, error.stack: ' + err.stack);
|
|
59
|
+
}
|
|
60
|
+
res.status(500).send('Error');
|
|
61
|
+
next(err);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
router.get('/_sitemap', (req, res, next) => {
|
|
65
|
+
return runner
|
|
66
|
+
.getSiteMap()
|
|
67
|
+
.then((result) => {
|
|
68
|
+
res.json(result);
|
|
69
|
+
})
|
|
70
|
+
.catch((err) => {
|
|
71
|
+
logger_1.default.error('Error fetching sitemap');
|
|
72
|
+
logger_1.default.debug('error getting sitemap from runner', { error: err.message || err });
|
|
73
|
+
if (lodash_1.default.has(err, 'stack')) {
|
|
74
|
+
logger_1.default.debug('error getting sitemap from runner, error.stack: ' + err.stack);
|
|
75
|
+
}
|
|
76
|
+
res.status(500).send('Error');
|
|
77
|
+
next(err);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
router.get('/_schema', (req, res, next) => {
|
|
81
|
+
return runner
|
|
82
|
+
.getSchema()
|
|
83
|
+
.then((schema) => res.json(schema))
|
|
84
|
+
.catch((err) => {
|
|
85
|
+
logger_1.default.error('Error fetching schema');
|
|
86
|
+
logger_1.default.debug('error getting schema from runner', { error: err });
|
|
87
|
+
res.status(500).send('Error');
|
|
88
|
+
next(err);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
router.get('/_pageUrl', (req, res, next) => {
|
|
92
|
+
const { entryId: objectId, spaceId: projectId, locale } = req.query;
|
|
93
|
+
runner
|
|
94
|
+
.getUrl(objectId, projectId, locale)
|
|
95
|
+
.then((url) => res.json({ url }))
|
|
96
|
+
.catch((err) => {
|
|
97
|
+
if (err !== response_errors_1.PageNotFoundError) {
|
|
98
|
+
logger_1.default.error('Error querying for page url');
|
|
99
|
+
}
|
|
100
|
+
const log = err === response_errors_1.PageNotFoundError ? logger_1.default.warn : logger_1.default.debug;
|
|
101
|
+
log('error getting page path from runner', { params: req.query, error: err });
|
|
102
|
+
res.json({ error: err.toString() });
|
|
103
|
+
next(err);
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
router.get('/_object', (req, res, next) => {
|
|
107
|
+
const { objectId, projectId } = req.query;
|
|
108
|
+
return runner
|
|
109
|
+
.getObject(objectId, projectId)
|
|
110
|
+
.then((response) => {
|
|
111
|
+
res.json(response);
|
|
112
|
+
})
|
|
113
|
+
.catch((err) => {
|
|
114
|
+
logger_1.default.error('Error fetching object');
|
|
115
|
+
logger_1.default.debug('error getting object', { error: err });
|
|
116
|
+
next(err);
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
router.post('/_object', [body_parser_1.default.json({ limit: '500kb' })], (req, res, next) => {
|
|
120
|
+
const { modelName, filePath, object, user } = req.body;
|
|
121
|
+
return runner
|
|
122
|
+
.createObject(modelName, filePath, object, user)
|
|
123
|
+
.then((response) => {
|
|
124
|
+
res.json(response);
|
|
125
|
+
})
|
|
126
|
+
.catch((err) => {
|
|
127
|
+
logger_1.default.error('Error creating object');
|
|
128
|
+
logger_1.default.debug('error creating object', { error: err });
|
|
129
|
+
next(err);
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
router.put('/_object', [body_parser_1.default.json({ limit: '500kb' })], (req, res, next) => {
|
|
133
|
+
const { objectId, projectId } = req.query;
|
|
134
|
+
const { object, user } = req.body;
|
|
135
|
+
return runner
|
|
136
|
+
.updateObject(objectId, projectId, object, user)
|
|
137
|
+
.then((response) => {
|
|
138
|
+
res.json(response);
|
|
139
|
+
})
|
|
140
|
+
.catch((err) => {
|
|
141
|
+
logger_1.default.error('Error updating object');
|
|
142
|
+
logger_1.default.debug('error updating object', { error: err });
|
|
143
|
+
next(err);
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
router.delete('/_object', [body_parser_1.default.json({ limit: '500kb' })], (req, res, next) => {
|
|
147
|
+
const { objectId } = req.query;
|
|
148
|
+
const { user } = req.body;
|
|
149
|
+
return runner
|
|
150
|
+
.deleteObject(objectId, user)
|
|
151
|
+
.then((response) => {
|
|
152
|
+
res.json(response);
|
|
153
|
+
})
|
|
154
|
+
.catch((err) => {
|
|
155
|
+
logger_1.default.error('Error deleting collections');
|
|
156
|
+
logger_1.default.debug('error deleting object', { error: err });
|
|
157
|
+
next(err);
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
router.get('/_assets', [body_parser_1.default.json({ limit: '500kb' })], (req, res, next) => {
|
|
161
|
+
const filterParams = lodash_1.default.pick(req.body, ['searchQuery', 'pageId', 'pageSize']);
|
|
162
|
+
return runner
|
|
163
|
+
.listAssets(filterParams)
|
|
164
|
+
.then((response) => {
|
|
165
|
+
res.json(response);
|
|
166
|
+
})
|
|
167
|
+
.catch((err) => {
|
|
168
|
+
logger_1.default.error('Error listing assets');
|
|
169
|
+
logger_1.default.debug('error listing assets', { error: err });
|
|
170
|
+
res.status(500).json({ error: err.toString() });
|
|
171
|
+
next(err);
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
router.post('/_assets', [body_parser_1.default.json({ limit: '500kb' })], (req, res, next) => {
|
|
175
|
+
const { url, filename, user } = req.body;
|
|
176
|
+
return runner
|
|
177
|
+
.uploadAsset(url, filename, user)
|
|
178
|
+
.then((response) => {
|
|
179
|
+
res.json(response);
|
|
180
|
+
})
|
|
181
|
+
.catch((err) => {
|
|
182
|
+
logger_1.default.error('Error adding asset');
|
|
183
|
+
logger_1.default.debug('error uploading asset', { error: err });
|
|
184
|
+
res.status(500).json({ error: err.toString() });
|
|
185
|
+
next(err);
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
exports.default = routes;
|
|
190
|
+
//# sourceMappingURL=routes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../../src/server/routes.ts"],"names":[],"mappings":";;;;;AAAA,oDAAuB;AAEvB,8DAAqC;AAErC,gEAAwC;AACxC,wFAAuF;AAEvF,SAAwB,MAAM,CAAC,MAAc,EAAE,MAAc;IACzD,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,GAAY,EAAE,GAAa,EAAE,EAAE;QACnD,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,qBAAU,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAE,EAAE;QAChH,MAAM,EAAE,SAAS,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC;QAC/B,OAAO,MAAM;aACR,UAAU,CAAC,SAAS,CAAC;aACrB,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;YACb,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACrB,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACX,gBAAM,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;YAC5C,gBAAM,CAAC,KAAK,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AC,IAAI,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YAChD,IAAI,CAAC,GAAG,CAAC,CAAC;QACd,CAAC,CAAC,CAAC;IACX,CAAC,CAAC,CAAC;AACP,CAAC;AAlLD,yBAkLC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const axios_1 = __importDefault(require("axios"));
|
|
7
|
+
const config_1 = __importDefault(require("../config"));
|
|
8
|
+
exports.default = {
|
|
9
|
+
updateLocalDev: (userId, localDevConfig) => {
|
|
10
|
+
return axios_1.default.post(`${config_1.default.apiUrl}/project/local/${userId}`, {
|
|
11
|
+
config: localDevConfig
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/services/api.ts"],"names":[],"mappings":";;;;;AAAA,kDAA0B;AAC1B,uDAA+B;AAE/B,kBAAe;IACX,cAAc,EAAE,CAAC,MAAc,EAAE,cAAmB,EAAE,EAAE;QACpD,OAAO,eAAK,CAAC,IAAI,CAAC,GAAG,gBAAM,CAAC,MAAM,kBAAkB,MAAM,EAAE,EAAE;YAC1D,MAAM,EAAE,cAAc;SACzB,CAAC,CAAC;IACP,CAAC;CACJ,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.watchDir = void 0;
|
|
7
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
+
const chokidar_1 = __importDefault(require("chokidar"));
|
|
9
|
+
function watchDir(dir, onFileChange, throttleDelay = 1000) {
|
|
10
|
+
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/')),
|
|
17
|
+
persistent: true,
|
|
18
|
+
ignoreInitial: true
|
|
19
|
+
});
|
|
20
|
+
let changedFiles = [];
|
|
21
|
+
const throttledFileChange = lodash_1.default.throttle(() => {
|
|
22
|
+
if (changedFiles.length) {
|
|
23
|
+
onFileChange(changedFiles);
|
|
24
|
+
changedFiles = [];
|
|
25
|
+
}
|
|
26
|
+
}, throttleDelay);
|
|
27
|
+
const handleFileChange = (filePath) => {
|
|
28
|
+
if (!changedFiles.includes(filePath)) {
|
|
29
|
+
changedFiles.push(filePath);
|
|
30
|
+
}
|
|
31
|
+
throttledFileChange();
|
|
32
|
+
};
|
|
33
|
+
watcher
|
|
34
|
+
.on('add', handleFileChange)
|
|
35
|
+
.on('change', handleFileChange)
|
|
36
|
+
.on('unlink', handleFileChange)
|
|
37
|
+
.on('addDir', handleFileChange)
|
|
38
|
+
.on('unlinkDir', handleFileChange);
|
|
39
|
+
return watcher;
|
|
40
|
+
}
|
|
41
|
+
exports.watchDir = watchDir;
|
|
42
|
+
//# sourceMappingURL=file-watcher.js.map
|
|
@@ -0,0 +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;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AAjCD,4BAiCC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createLogger = void 0;
|
|
7
|
+
const winston_1 = __importDefault(require("winston"));
|
|
8
|
+
const config_1 = __importDefault(require("../config"));
|
|
9
|
+
const defaultFormats = [winston_1.default.format.colorize(), winston_1.default.format.simple()];
|
|
10
|
+
const transports = [
|
|
11
|
+
new winston_1.default.transports.Console({
|
|
12
|
+
format: winston_1.default.format.combine(...defaultFormats)
|
|
13
|
+
})
|
|
14
|
+
];
|
|
15
|
+
const logger = winston_1.default.createLogger({
|
|
16
|
+
level: config_1.default.logLevel,
|
|
17
|
+
transports: transports
|
|
18
|
+
});
|
|
19
|
+
const createLogger = ({ label }) => {
|
|
20
|
+
const formats = defaultFormats.slice();
|
|
21
|
+
if (label) {
|
|
22
|
+
formats.push(winston_1.default.format.label({
|
|
23
|
+
label: label,
|
|
24
|
+
message: true
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
return winston_1.default.createLogger({
|
|
28
|
+
level: config_1.default.logLevel,
|
|
29
|
+
format: winston_1.default.format.combine(...formats),
|
|
30
|
+
transports: transports
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
exports.createLogger = createLogger;
|
|
34
|
+
exports.default = logger;
|
|
35
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/services/logger.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA8B;AAC9B,uDAA+B;AAE/B,MAAM,cAAc,GAAG,CAAC,iBAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,iBAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;AAE5E,MAAM,UAAU,GAAG;IACf,IAAI,iBAAO,CAAC,UAAU,CAAC,OAAO,CAAC;QAC3B,MAAM,EAAE,iBAAO,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,cAAc,CAAC;KACpD,CAAC;CACL,CAAC;AAEF,MAAM,MAAM,GAAG,iBAAO,CAAC,YAAY,CAAC;IAChC,KAAK,EAAE,gBAAM,CAAC,QAAQ;IACtB,UAAU,EAAE,UAAU;CACzB,CAAC,CAAC;AAEI,MAAM,YAAY,GAAG,CAAC,EAAE,KAAK,EAAqB,EAAE,EAAE;IACzD,MAAM,OAAO,GAAG,cAAc,CAAC,KAAK,EAAE,CAAC;IACvC,IAAI,KAAK,EAAE;QACP,OAAO,CAAC,IAAI,CACR,iBAAO,CAAC,MAAM,CAAC,KAAK,CAAC;YACjB,KAAK,EAAE,KAAK;YACZ,OAAO,EAAE,IAAI;SAChB,CAAC,CACL,CAAC;KACL;IACD,OAAO,iBAAO,CAAC,YAAY,CAAC;QACxB,KAAK,EAAE,gBAAM,CAAC,QAAQ;QACtB,MAAM,EAAE,iBAAO,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;QAC1C,UAAU,EAAE,UAAU;KACzB,CAAC,CAAC;AACP,CAAC,CAAC;AAfW,QAAA,YAAY,gBAevB;AAEF,kBAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createTunnel(port: number, logger: any): Promise<string>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createTunnel = void 0;
|
|
7
|
+
const ngrok_1 = __importDefault(require("ngrok"));
|
|
8
|
+
async function createTunnel(port, logger) {
|
|
9
|
+
return ngrok_1.default.connect({
|
|
10
|
+
addr: port,
|
|
11
|
+
onStatusChange: (status) => {
|
|
12
|
+
logger === null || logger === void 0 ? void 0 : logger.debug('Tunnel status: ' + status);
|
|
13
|
+
},
|
|
14
|
+
onLogEvent: (data) => { }
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
exports.createTunnel = createTunnel;
|
|
18
|
+
//# sourceMappingURL=ngrok.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ngrok.js","sourceRoot":"","sources":["../../src/services/ngrok.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAEnB,KAAK,UAAU,YAAY,CAAC,IAAY,EAAE,MAAW;IACxD,OAAO,eAAK,CAAC,OAAO,CAAC;QACjB,IAAI,EAAE,IAAI;QACV,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE;YACvB,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,iBAAiB,GAAG,MAAM,CAAC,CAAC;QAC9C,CAAC;QACD,UAAU,EAAE,CAAC,IAAI,EAAE,EAAE,GAAE,CAAC;KAC3B,CAAC,CAAC;AACP,CAAC;AARD,oCAQC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getUserId(): any;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getUserId = void 0;
|
|
7
|
+
const configstore_1 = __importDefault(require("configstore"));
|
|
8
|
+
const uuid_1 = __importDefault(require("uuid"));
|
|
9
|
+
const config = new configstore_1.default('stackbit-dev', {
|
|
10
|
+
userId: uuid_1.default.v4().toString().replace(/\-/g, '')
|
|
11
|
+
}, { globalConfigPath: true });
|
|
12
|
+
function getUserId() {
|
|
13
|
+
return config.get('userId');
|
|
14
|
+
}
|
|
15
|
+
exports.getUserId = getUserId;
|
|
16
|
+
//# sourceMappingURL=user-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-config.js","sourceRoot":"","sources":["../../src/services/user-config.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAsC;AACtC,gDAAwB;AAExB,MAAM,MAAM,GAAG,IAAI,qBAAW,CAC1B,cAAc,EACd;IACI,MAAM,EAAE,cAAI,CAAC,EAAE,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;CAClD,EACD,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAC7B,CAAC;AAEF,SAAgB,SAAS;IACrB,OAAO,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAChC,CAAC;AAFD,8BAEC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stackbit/dev",
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"description": "stackbit-dev",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"stackbit": "./dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"/dist",
|
|
12
|
+
"/src"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"test": "jest --passWithNoTests",
|
|
16
|
+
"build": "npm run clean && npm run copy-files && tsc",
|
|
17
|
+
"clean": "rimraf dist/",
|
|
18
|
+
"prettier": "prettier --write src",
|
|
19
|
+
"prepack": "npm test && npm run build",
|
|
20
|
+
"copy-files": "copyfiles -u 1 src/assets/* dist/"
|
|
21
|
+
},
|
|
22
|
+
"author": "Stackbit Inc.",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@stackbit/cms-core": "^0.0.3",
|
|
26
|
+
"@stackbit/dev-common": "^0.0.3",
|
|
27
|
+
"@stackbit/sdk": "^0.2.22",
|
|
28
|
+
"axios": "^0.25.0",
|
|
29
|
+
"chalk": "^4.1.0",
|
|
30
|
+
"chokidar": "^3.5.3",
|
|
31
|
+
"configstore": "^5",
|
|
32
|
+
"cors": "^2.8.5",
|
|
33
|
+
"detect-port": "^1.3.0",
|
|
34
|
+
"express": "^4.17.2",
|
|
35
|
+
"fs-extra": "^10.0.0",
|
|
36
|
+
"http-proxy-middleware": "^0.20.0",
|
|
37
|
+
"lodash": "^4.17.21",
|
|
38
|
+
"ngrok": "^4.3.0",
|
|
39
|
+
"rimraf": "^3.0.2",
|
|
40
|
+
"uuid": "^3.4.0",
|
|
41
|
+
"winston": "^3.4.0",
|
|
42
|
+
"yargs": "^17.3.1"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@types/axios": "^0.14.0",
|
|
46
|
+
"@types/configstore": "^5.0.1",
|
|
47
|
+
"@types/detect-port": "^1.3.2",
|
|
48
|
+
"@types/express": "^4.17.13",
|
|
49
|
+
"@types/http-proxy-middleware": "^1.0.0",
|
|
50
|
+
"@types/lodash": "^4.14.178",
|
|
51
|
+
"@types/uuid": "^8.3.4",
|
|
52
|
+
"copyfiles": "^2.4.1",
|
|
53
|
+
"jest": "^27.4.7",
|
|
54
|
+
"prettier": "^2.5.1",
|
|
55
|
+
"ts-jest": "^27.1.3",
|
|
56
|
+
"typescript": "^4.5.4"
|
|
57
|
+
},
|
|
58
|
+
"gitHead": "c11e30670c8a59ed67503af36febe8fccfd1e2cc"
|
|
59
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>Stackbit</title>
|
|
6
|
+
<style type="text/css">
|
|
7
|
+
body {
|
|
8
|
+
margin: 0;
|
|
9
|
+
padding: 0;
|
|
10
|
+
}
|
|
11
|
+
#main-container {
|
|
12
|
+
color: #fff;
|
|
13
|
+
background: #22252d;
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
align-items: center;
|
|
17
|
+
justify-content: center;
|
|
18
|
+
font-family: sans-serif;
|
|
19
|
+
height: 100vh;
|
|
20
|
+
text-align: center;
|
|
21
|
+
}
|
|
22
|
+
h1 {
|
|
23
|
+
font-weight: 400;
|
|
24
|
+
font-size: 34px;
|
|
25
|
+
}
|
|
26
|
+
#logo {
|
|
27
|
+
margin-bottom: 16px;
|
|
28
|
+
width: 78px;
|
|
29
|
+
height: 69px;
|
|
30
|
+
fill: #f25458;
|
|
31
|
+
}
|
|
32
|
+
#info-text a {
|
|
33
|
+
color: #fff;
|
|
34
|
+
}
|
|
35
|
+
</style>
|
|
36
|
+
</head>
|
|
37
|
+
<body>
|
|
38
|
+
<div id="main-container">
|
|
39
|
+
<svg id="logo" width="26" height="23" viewBox="0 0 23 23" fill="#fff"><path d="M5.728 0C4.533 0 3.387.47 2.542 1.304a4.426 4.426 0 00-1.32 3.149v6.68c0 .55.155 1.091.447 1.56.293.47.71.85 1.209 1.1l5.87 2.922V7.42h9.406L25.65 0H5.728z"></path><path d="M19.92 22.684a4.542 4.542 0 003.188-1.303 4.417 4.417 0 001.322-3.146v-6.672a2.951 2.951 0 00-.45-1.557 3.007 3.007 0 00-1.208-1.096L16.93 5.97v9.286H7.515L0 22.684h19.92z"></path></svg>
|
|
40
|
+
<h1>Local Server Unavailable</h1>
|
|
41
|
+
<div id="info-text">Is your site running and available at <a href="__URL__" target="_blank">__URL__</a>?</div>
|
|
42
|
+
</div>
|
|
43
|
+
<script type="application/javascript">
|
|
44
|
+
function poll() {
|
|
45
|
+
fetch('/', { method: 'HEAD' }).then((response) => {
|
|
46
|
+
window.location = "__PATH__";
|
|
47
|
+
}).catch(err => {
|
|
48
|
+
window.setTimeout(poll, 1000);
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
poll();
|
|
52
|
+
</script>
|
|
53
|
+
</body>
|
|
54
|
+
</html>
|
package/src/config.ts
ADDED
package/src/consts.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
NEXTJS_SOURCEBIT_LIVE_UPDATE_PORT: 8088,
|
|
3
|
+
DEFAULT_DIRECT_PROXY_PATH: [
|
|
4
|
+
'/socket.io/**',
|
|
5
|
+
'/__webpack_hmr/**',
|
|
6
|
+
'/sockjs-node/**',
|
|
7
|
+
'**/*.js',
|
|
8
|
+
'**/*.js.map',
|
|
9
|
+
'**/*.css',
|
|
10
|
+
'**/*.css.map',
|
|
11
|
+
'**/*.json',
|
|
12
|
+
'**/*.png',
|
|
13
|
+
'**/*.jpg',
|
|
14
|
+
'**/*.jpeg',
|
|
15
|
+
'**/*.gif',
|
|
16
|
+
'**/*.svg',
|
|
17
|
+
'**/*.ico',
|
|
18
|
+
'**/*.pdf',
|
|
19
|
+
'**/*.otf',
|
|
20
|
+
'**/*.ttf',
|
|
21
|
+
'**/*.tif',
|
|
22
|
+
'**/*.tiff',
|
|
23
|
+
'**/*.mp4',
|
|
24
|
+
'**/*.mkv',
|
|
25
|
+
'**/*.mov',
|
|
26
|
+
'**/*.wmv',
|
|
27
|
+
'**/*.zip',
|
|
28
|
+
'**/*.xml',
|
|
29
|
+
'**/*.ppt',
|
|
30
|
+
'**/*.pptx',
|
|
31
|
+
'**/*.doc',
|
|
32
|
+
'**/*.docx',
|
|
33
|
+
'**/*.xls',
|
|
34
|
+
'**/*.xlsx',
|
|
35
|
+
'**/*.rtf'
|
|
36
|
+
],
|
|
37
|
+
ASSET_ID_PREFIX: 'stackbit_asset_id',
|
|
38
|
+
STATIC_ASSETS_FILE_PATH: '.cache/static-app-assets',
|
|
39
|
+
STATIC_ASSETS_PUBLIC_PATH: '/_static/app-assets',
|
|
40
|
+
STATIC_THEME_ASSETS_FILE_PATH: '.cache/static-theme-assets',
|
|
41
|
+
STATIC_THEME_ASSETS_PUBLIC_PATH: '/_static/theme-assets',
|
|
42
|
+
STACKBIT_URL_PATH_FIELD: 'stackbit_url_path',
|
|
43
|
+
DEFAULT_CONTENT_TYPE_EXTENSIONS: ['md', 'markdown', 'mdx', 'yml', 'yaml', 'json', 'toml']
|
|
44
|
+
};
|
package/src/dev.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import { parse as parseUrl } from 'url';
|
|
3
|
+
import detectPort from 'detect-port';
|
|
4
|
+
|
|
5
|
+
import { start as startServer } from './server';
|
|
6
|
+
import { createTunnel } from './services/ngrok';
|
|
7
|
+
import { getUserId } from './services/user-config';
|
|
8
|
+
import logger from './services/logger';
|
|
9
|
+
import apiService from './services/api';
|
|
10
|
+
import config from './config';
|
|
11
|
+
import chalk from 'chalk';
|
|
12
|
+
|
|
13
|
+
export async function start({
|
|
14
|
+
ssgPort = 3000,
|
|
15
|
+
ssgHost = 'localhost',
|
|
16
|
+
rootDir = process.cwd(),
|
|
17
|
+
runnableDir
|
|
18
|
+
}: {
|
|
19
|
+
ssgPort: number;
|
|
20
|
+
ssgHost: string;
|
|
21
|
+
rootDir: string;
|
|
22
|
+
runnableDir?: string;
|
|
23
|
+
}) {
|
|
24
|
+
logger.info('Site directory: ' + rootDir);
|
|
25
|
+
|
|
26
|
+
let serverPort = await detectPort(8090);
|
|
27
|
+
const userId = getUserId();
|
|
28
|
+
logger.debug('id: ' + userId);
|
|
29
|
+
|
|
30
|
+
let url;
|
|
31
|
+
try {
|
|
32
|
+
url = await createTunnel(serverPort, logger);
|
|
33
|
+
logger.debug('Server created', { url });
|
|
34
|
+
} catch (err) {
|
|
35
|
+
logger.error('Error starting ngrok');
|
|
36
|
+
logger.debug('createTunnel failed', { err });
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
await startServer({ serverPort, ssgHost, ssgPort, rootDir, runnableDir });
|
|
42
|
+
} catch (err) {
|
|
43
|
+
logger.error('Error starting Stackbit dev server');
|
|
44
|
+
logger.debug('startServer failed', { err });
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const localDetails = {
|
|
49
|
+
i: userId,
|
|
50
|
+
h: parseUrl(url).hostname?.split('.')[0],
|
|
51
|
+
v: require('../package.json').version
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
logger.debug('Local details', { localDetails });
|
|
55
|
+
const studioUrl = `${config.appUrl}/local/${Buffer.from(JSON.stringify(localDetails)).toString('base64')}`;
|
|
56
|
+
|
|
57
|
+
try {
|
|
58
|
+
await apiService.updateLocalDev(userId, localDetails);
|
|
59
|
+
} catch (err) {
|
|
60
|
+
logger.debug('updateLocalDev failed', { err });
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
logger.info(`Server started. Forwarding requests to: ${ssgHost}:${ssgPort}`);
|
|
64
|
+
logger.info(`Open ${chalk.bold(studioUrl)} in your browser`);
|
|
65
|
+
}
|