mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-10 04:22:12 +00:00
* Add API for frameworks and examples * Adjust headers * Update frameworks list * Always use latest * Add types * Use now repo for downloading and listing * Use .existsSync * Remove unused packages * Use 307 for redirect * Add examples * Update tsconfig.json Co-Authored-By: Steven <steven@ceriously.com> * Make examples unique * Remove detectors from frameworks API * Use /api instead of Next.js * Install dependencies * Rename project * Change name * Empty * Change name * Update api/tsconfig.json Co-Authored-By: Steven <steven@ceriously.com> * Update examples Co-authored-by: Steven <steven@ceriously.com>
47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
import { extract } from '../_lib/examples/extract';
|
|
import { summary } from '../_lib/examples/summary';
|
|
import { NowRequest, NowResponse } from '@now/node';
|
|
import { mapOldToNew } from '../_lib/examples/map-old-to-new';
|
|
import { withApiHandler } from '../_lib/util/with-api-handler';
|
|
|
|
export default withApiHandler(async function(
|
|
req: NowRequest,
|
|
res: NowResponse
|
|
) {
|
|
if (Number(req.query.version) === 1) {
|
|
// The old cli is pinned to a specific commit hash
|
|
await extract(
|
|
'https://github.com/zeit/now-examples/archive/7c7b27e49b8b17d0d3f0e1604dc74fd005cd69e3.zip',
|
|
'/tmp'
|
|
);
|
|
const exampleList = summary(
|
|
'/tmp/now-examples-7c7b27e49b8b17d0d3f0e1604dc74fd005cd69e3'
|
|
);
|
|
return res.send(exampleList);
|
|
}
|
|
|
|
await Promise.all([
|
|
extract('https://github.com/zeit/now/archive/master.zip', '/tmp'),
|
|
extract('https://github.com/zeit/now-examples/archive/master.zip', '/tmp'),
|
|
]);
|
|
|
|
const exampleList = new Set([
|
|
...summary('/tmp/now-master/examples'),
|
|
...summary('/tmp/now-examples-master'),
|
|
]);
|
|
|
|
const existingExamples = Array.from(exampleList).map(key => ({
|
|
name: key,
|
|
visible: true,
|
|
suggestions: [],
|
|
}));
|
|
|
|
const oldExamples = Object.keys(mapOldToNew).map(key => ({
|
|
name: key,
|
|
visible: false,
|
|
suggestions: mapOldToNew[key],
|
|
}));
|
|
|
|
res.status(200).json([...existingExamples, ...oldExamples]);
|
|
});
|