Skip to content
Permalink
Browse files

Adds manifest.json to examples folder (#3536)

* Revert "Revert "[examples] Add manifest.json""

This reverts commit c65336e.

* Revert "Revert "Do not use now-examples anymore""

This reverts commit ac72e94.

* Update nowignore

* Fix join

* Fix JSON

* Fix header

* Replace manifest.json with @now/frameworks

* Adjust readmes

* Adjust .nowignore

* Update scully

* Fix description

* Update examples/create-react-app/src/App.js

Co-Authored-By: Shu Ding <ds303077135@gmail.com>

* Update readme

* Add websites

* Use https

* Adjust example URL

* Change order

Co-authored-by: Shu Ding <ds303077135@gmail.com>
  • Loading branch information
AndyBitz and quietshu committed Jan 9, 2020
1 parent 7064f4e commit 2db627b79d9839ec092f11d4510e470fef6539af
Showing with 9,365 additions and 562 deletions.
  1. +22 −18 api/_lib/examples/example-list.ts
  2. +5 −4 api/_lib/examples/github-repo-info.ts
  3. +1 −0 api/_lib/examples/map-old-to-new.ts
  4. +2 −8 api/examples/download/[segment].ts
  5. +2 −9 api/examples/list.ts
  6. +1 −1 examples/angular/README.md
  7. +0 −28 examples/create-react-app-functions/.gitignore
  8. +0 −29 examples/create-react-app-functions/README.md
  9. +0 −22 examples/create-react-app-functions/package.json
  10. +0 −44 examples/create-react-app-functions/src/App.css
  11. +0 −57 examples/create-react-app-functions/src/App.js
  12. +0 −9 examples/create-react-app-functions/src/App.test.js
  13. +0 −14 examples/create-react-app-functions/src/index.css
  14. +0 −12 examples/create-react-app-functions/src/index.js
  15. +0 −135 examples/create-react-app-functions/src/serviceWorker.js
  16. +2 −1 examples/create-react-app/.gitignore
  17. +8 −8 examples/create-react-app/README.md
  18. 0 examples/{create-react-app-functions → create-react-app}/api/date.go
  19. 0 examples/{create-react-app-functions → create-react-app}/api/go.mod
  20. +10 −17 examples/create-react-app/package.json
  21. +10 −5 examples/create-react-app/public/index.html
  22. +40 −29 examples/create-react-app/src/App.css
  23. +44 −13 examples/create-react-app/src/App.js
  24. +1 −0 examples/create-react-app/src/index.css
  25. +0 −7 examples/create-react-app/src/logo.svg
  26. +2 −2 examples/create-react-app/src/serviceWorker.js
  27. +1 −1 examples/docusaurus/README.md
  28. +1 −1 examples/eleventy/README.md
  29. +1 −1 examples/gatsby-functions/README.md
  30. +1 −1 examples/gatsby/README.md
  31. +1 −1 examples/gridsome/README.md
  32. +1 −1 examples/hexo/README.md
  33. +1 −1 examples/nextjs/README.md
  34. +1 −1 examples/polymer/README.md
  35. +1 −1 examples/preact/README.md
  36. +1 −1 examples/saber/README.md
  37. +4 −0 examples/scully/.angulardoc.json
  38. +13 −0 examples/scully/.editorconfig
  39. +46 −0 examples/scully/.gitignore
  40. +1 −1 examples/scully/README.md
  41. +5 −3 examples/scully/angular.json
  42. +7 −0 examples/scully/blog/first-post.md
  43. +7 −0 examples/scully/blog/second-post.md
  44. +1 −1 examples/scully/karma.conf.js
  45. +29 −30 examples/scully/package.json
  46. +8 −1 examples/scully/scully.config.js
  47. +15 −0 examples/scully/src/app/app-routing.module.ts
  48. +9 −3 examples/scully/src/app/app.component.html
  49. +8 −6 examples/scully/src/app/app.component.spec.ts
  50. +18 −5 examples/scully/src/app/app.component.ts
  51. +2 −1 examples/scully/src/app/app.module.ts
  52. +17 −0 examples/scully/src/app/blog/blog-routing.module.ts
  53. +10 −0 examples/scully/src/app/blog/blog.component.css
  54. +7 −0 examples/scully/src/app/blog/blog.component.html
  55. +24 −0 examples/scully/src/app/blog/blog.component.spec.ts
  56. +17 −0 examples/scully/src/app/blog/blog.component.ts
  57. +11 −0 examples/scully/src/app/blog/blog.module.ts
  58. +14 −1 examples/scully/src/assets/scully-routes.json
  59. +1 −1 examples/scully/src/index.html
  60. +20 −0 examples/scully/src/test.ts
  61. +1 −2 examples/scully/tsconfig.app.json
  62. +1 −1 examples/scully/tsconfig.json
  63. +8,802 −0 examples/scully/yarn.lock
  64. +1 −1 examples/svelte/README.md
  65. +0 −2 examples/umi/.env
  66. +0 −2 examples/umi/.nowignore
  67. 0 examples/umi/mock/.gitkeep
  68. 0 examples/{umi → umijs}/.editorconfig
  69. 0 examples/{umi → umijs}/.gitignore
  70. 0 examples/{create-react-app-functions → umijs}/.nowignore
  71. 0 examples/{umi → umijs}/.prettierignore
  72. 0 examples/{umi → umijs}/.prettierrc
  73. 0 examples/{umi → umijs}/.umirc.ts
  74. +1 −1 examples/{umi → umijs}/README.md
  75. 0 examples/{scully/src/assets → umijs/mock}/.gitkeep
  76. 0 examples/{umi → umijs}/package.json
  77. BIN examples/{umi → umijs}/src/assets/yay.jpg
  78. 0 examples/{umi → umijs}/src/global.css
  79. 0 examples/{umi → umijs}/src/layouts/__tests__/index.test.tsx
  80. 0 examples/{umi → umijs}/src/layouts/index.css
  81. 0 examples/{umi → umijs}/src/layouts/index.tsx
  82. 0 examples/{umi → umijs}/src/pages/__tests__/index.test.tsx
  83. 0 examples/{umi → umijs}/src/pages/index.css
  84. 0 examples/{umi → umijs}/src/pages/index.tsx
  85. 0 examples/{umi → umijs}/tsconfig.json
  86. 0 examples/{umi → umijs}/tslint.yml
  87. 0 examples/{umi → umijs}/typings.d.ts
  88. +1 −1 examples/vue/README.md
  89. +1 −1 now.json
  90. +100 −15 packages/frameworks/frameworks.json
  91. +3 −1 packages/frameworks/index.d.ts
@@ -1,21 +1,25 @@
// Currently we read & parse the README file from zeit/now-examples
// TODO: create a `manifest.json` for zeit/now-examples
import Frameworks, { Framework } from '../../../packages/frameworks';

import fetch from 'node-fetch';

/**
* Fetch and parse the `Frameworks and Libraries` table
* in the README file of zeit/now-examples
*/
export async function getExampleList() {
const response = await fetch(
`https://raw.githubusercontent.com/zeit/now-examples/master/manifest.json`
);

if (response.status !== 200) {
console.log('manifest.json missing in zeit/now-examples');
return null;
}
interface Example {
example: string;
path: string;
demo: string;
description: string;
tagline: string;
framework: string;
}

return response.json();
export async function getExampleList(): Promise<Example[]> {
return (Frameworks as Framework[])
.filter(f => f.demo)
.map(framework => {
return {
example: framework.name,
path: `/${framework.slug}`,
demo: framework.demo,
description: framework.description,
tagline: framework.tagline,
framework: framework.slug,
};
});
}
@@ -10,9 +10,9 @@ export async function getGitHubRepoInfo(repo: Repo) {
const response = await fetch(`https://api.github.com/repos/${repo.repo}`, {
headers: {
Accept: 'application/vnd.github.machine-man-preview+json',
// If we don't use a personal access token,
// If we don't use a personal access token,
// it will get rate limited very easily.
Authorization: `Bearer ${process.env.GITHUB_ACCESS_TOKEN}`
Authorization: `Bearer ${process.env.GITHUB_ACCESS_TOKEN}`,
},
});

@@ -51,7 +51,9 @@ export async function getGitHubRepoInfo(repo: Repo) {
data.subdir = repo.path.slice(subdirPath.length).split('/');
}

if (data.id === 'zeit/now-examples' && data.subdir) {
const isExamples = data.id === 'zeit/now-examples' || data.id === 'zeit/now';

if (isExamples && data.subdir) {
// from our examples, add `homepage` and `description` fields
const example = data.subdir[0];
const exampleList = await getExampleList();
@@ -61,7 +63,6 @@ export async function getGitHubRepoInfo(repo: Repo) {
data.homepage = item.demo;
data.description = item.description;
data.exampleName = item.example;
data.icon = item.icon;
data.tagline = item.tagline;
data.framework = item.framework;
return data;
@@ -21,6 +21,7 @@ export const mapOldToNew: { [key: string]: string[] } = {
'nuxt-static': ['nuxtjs'],
static: ['vanilla'],
typescript: ['gatsby-functions'],
umi: ['umijs'],
'vanilla-go': ['vanilla-functions'],
'vanilla-json-api': ['svelte-functions'],
'vue-ssr': ['vue'],
@@ -51,14 +51,8 @@ export default withApiHandler(async function(req: NowRequest, res: NowResponse)
await extract('https://github.com/zeit/now-examples/archive/7c7b27e49b8b17d0d3f0e1604dc74fd005cd69e3.zip', TMP_DIR);
directory = `${TMP_DIR}/now-examples-7c7b27e49b8b17d0d3f0e1604dc74fd005cd69e3/${example}`;
} else {
await extract('https://github.com/zeit/now-examples/archive/master.zip', TMP_DIR);
directory = `${TMP_DIR}/now-examples-master/${example}`;

if (!isDirectory(directory)) {
// Use `now` instead of `now-examples` if the searched example does not exist
await extract('https://github.com/zeit/now/archive/master.zip', TMP_DIR);
directory = `${TMP_DIR}/now-master/examples/${example}`;
}
await extract('https://github.com/zeit/now/archive/master.zip', TMP_DIR);
directory = `${TMP_DIR}/now-master/examples/${example}`;
}

if (!isDirectory(directory)) {
@@ -20,15 +20,8 @@ export default withApiHandler(async function(
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'),
]);
await extract('https://github.com/zeit/now/archive/master.zip', '/tmp');
const exampleList = summary('/tmp/now-master/examples');

const existingExamples = Array.from(exampleList).map(key => ({
name: key,
@@ -1,4 +1,4 @@
![Angular Logo](../.github/images/angular.svg)
![Angular Logo](../packages/frameworks/logos/angular.svg)

# Angular Example

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

1 comment on commit 2db627b

@now

This comment has been minimized.

Please sign in to comment.
You can’t perform that action at this time.