Compare commits
5 Commits
main
...
refactor_s
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2fb2aefa23 | ||
|
|
975887c127 | ||
|
|
cea928af7d | ||
|
|
3d63bc2e2a | ||
|
|
1a1a485927 |
@ -1,6 +1,5 @@
|
|||||||
{
|
{
|
||||||
"extends": [
|
"extends": [
|
||||||
"plugin:@nrwl/nx/react-typescript",
|
|
||||||
"next",
|
"next",
|
||||||
"next/core-web-vitals",
|
"next/core-web-vitals",
|
||||||
"../../.eslintrc.json"
|
"../../.eslintrc.json"
|
||||||
|
|||||||
@ -1,17 +1,46 @@
|
|||||||
This is a repo intended to serve as an example of a data catalog that get its data from a CKAN Instance.
|
This is a repo intended to serve as an example of a data catalog that get its data from a CKAN Instance.
|
||||||
|
|
||||||
- Creating a new file inside o `examples` with `create-next-app` like so:
|
|
||||||
```
|
```
|
||||||
npx create-next-app <app-name> --example https://github.com/datopian/portaljs/tree/main/ --example-path examples/ckan-example
|
npx create-next-app <app-name> --example https://github.com/datopian/portaljs/tree/main/examples/ckan-example
|
||||||
|
cd <app-name>
|
||||||
```
|
```
|
||||||
- Inside `<app-name>` go to the `project.json` file and replace all instances of `ckan-example` with `<app-name>`
|
|
||||||
- Set the `DMS` env variable to the Url of the CKAN Instance Ex: `export DMS=https://demo.dev.datopian.com`
|
- This project uses CKAN as a backend, so you need to point the project to the CKAN Url desired, you can do so by setting up the `DMS` env variable in your terminal or adding a `.env` file with the following content:
|
||||||
|
|
||||||
|
```
|
||||||
|
DMS=<ckan url>
|
||||||
|
```
|
||||||
|
|
||||||
- Run the app using:
|
- Run the app using:
|
||||||
|
|
||||||
```
|
```
|
||||||
nx serve <app-name>
|
npm run dev
|
||||||
```
|
```
|
||||||
|
|
||||||
Congratulations, you now have something similar to this running on `http://localhost:4200`
|
Congratulations, you now have something similar to this running on `http://localhost:4200`
|
||||||

|

|
||||||
If yo go to any one of those pages by clicking on `More info` you will see something similar to this
|
If yo go to any one of those pages by clicking on `More info` you will see something similar to this
|
||||||

|

|
||||||
|
|
||||||
|
## Deployment
|
||||||
|
|
||||||
|
[](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fdatopian%2Fportaljs%2Ftree%2Fmain%2Fexamples%2Fckan-example&env=DMS&envDescription=URL%20For%20the%20CKAN%20Backend%20Ex%3A%20https%3A%2F%2Fdemo.dev.datopian.com)
|
||||||
|
|
||||||
|
By clicking on this button, you will be redirected to a page which will allow you to clone the content into your own github/gitlab/bitbucket account and automatically deploy everything.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Extra commands
|
||||||
|
|
||||||
|
You can also build the project for production with
|
||||||
|
|
||||||
|
```
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
And run using the production build like so:
|
||||||
|
|
||||||
|
```
|
||||||
|
npm run start
|
||||||
|
```
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +1,3 @@
|
|||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
||||||
const { withNx } = require('@nrwl/next/plugins/with-nx');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {import('@nrwl/next/plugins/with-nx').WithNxOptions}
|
|
||||||
**/
|
|
||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
publicRuntimeConfig: {
|
publicRuntimeConfig: {
|
||||||
DMS: process.env.DMS ? process.env.DMS : '',
|
DMS: process.env.DMS ? process.env.DMS : '',
|
||||||
@ -18,11 +12,6 @@ const nextConfig = {
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
nx: {
|
|
||||||
// Set this to true if you would like to use SVGR
|
|
||||||
// See: https://github.com/gregberge/svgr
|
|
||||||
svgr: false,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = withNx(nextConfig);
|
module.exports = nextConfig;
|
||||||
|
|||||||
5842
examples/ckan-example/package-lock.json
generated
Normal file
5842
examples/ckan-example/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
33
examples/ckan-example/package.json
Normal file
33
examples/ckan-example/package.json
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"name": "my-app",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"dev": "next dev",
|
||||||
|
"build": "next build",
|
||||||
|
"start": "next start",
|
||||||
|
"lint": "next lint"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@heroicons/react": "^2.0.17",
|
||||||
|
"@types/node": "18.16.0",
|
||||||
|
"@types/react": "18.0.38",
|
||||||
|
"@types/react-dom": "18.0.11",
|
||||||
|
"eslint": "8.39.0",
|
||||||
|
"eslint-config-next": "13.3.1",
|
||||||
|
"next": "13.3.1",
|
||||||
|
"next-seo": "^6.0.0",
|
||||||
|
"octokit": "^2.0.14",
|
||||||
|
"react": "18.2.0",
|
||||||
|
"react-dom": "18.2.0",
|
||||||
|
"react-markdown": "^8.0.7",
|
||||||
|
"remark-gfm": "^3.0.1",
|
||||||
|
"typescript": "5.0.4"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@tailwindcss/typography": "^0.5.9",
|
||||||
|
"autoprefixer": "^10.4.14",
|
||||||
|
"postcss": "^8.4.23",
|
||||||
|
"tailwindcss": "^3.3.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,15 +1,6 @@
|
|||||||
const { join } = require('path');
|
|
||||||
|
|
||||||
// Note: If you use library-specific PostCSS/Tailwind configuration then you should remove the `postcssConfig` build
|
|
||||||
// option from your application's configuration (i.e. project.json).
|
|
||||||
//
|
|
||||||
// See: https://nx.dev/guides/using-tailwind-css-in-react#step-4:-applying-configuration-to-libraries
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
plugins: {
|
plugins: {
|
||||||
tailwindcss: {
|
tailwindcss: {},
|
||||||
config: join(__dirname, 'tailwind.config.js'),
|
|
||||||
},
|
|
||||||
autoprefixer: {},
|
autoprefixer: {},
|
||||||
},
|
},
|
||||||
};
|
}
|
||||||
|
|||||||
@ -1,17 +1,15 @@
|
|||||||
const { createGlobPatternsForDependencies } = require('@nrwl/react/tailwind');
|
|
||||||
const { join } = require('path');
|
|
||||||
|
|
||||||
/** @type {import('tailwindcss').Config} */
|
/** @type {import('tailwindcss').Config} */
|
||||||
module.exports = {
|
module.exports = {
|
||||||
content: [
|
content: [
|
||||||
join(
|
"./app/**/*.{js,ts,jsx,tsx,mdx}",
|
||||||
__dirname,
|
"./pages/**/*.{js,ts,jsx,tsx,mdx}",
|
||||||
'{src,pages,components}/**/*!(*.stories|*.spec).{ts,tsx,html}'
|
"./components/**/*.{js,ts,jsx,tsx,mdx}",
|
||||||
),
|
|
||||||
...createGlobPatternsForDependencies(__dirname),
|
|
||||||
],
|
],
|
||||||
theme: {
|
theme: {
|
||||||
extend: {},
|
extend: {},
|
||||||
},
|
},
|
||||||
plugins: [],
|
plugins: [
|
||||||
};
|
require('@tailwindcss/typography')
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,23 +1,20 @@
|
|||||||
{
|
{
|
||||||
"extends": "../../tsconfig.base.json",
|
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"jsx": "preserve",
|
"target": "es5",
|
||||||
|
"lib": ["dom", "dom.iterable", "esnext"],
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"esModuleInterop": true,
|
"skipLibCheck": true,
|
||||||
"allowSyntheticDefaultImports": true,
|
|
||||||
"strict": false,
|
"strict": false,
|
||||||
"forceConsistentCasingInFileNames": true,
|
"forceConsistentCasingInFileNames": true,
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"module": "esnext",
|
||||||
|
"moduleResolution": "node",
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"isolatedModules": true,
|
"isolatedModules": true,
|
||||||
"incremental": true,
|
"jsx": "preserve",
|
||||||
"types": ["jest", "node"]
|
"incremental": true
|
||||||
},
|
},
|
||||||
"include": ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx", "next-env.d.ts"],
|
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
|
||||||
"exclude": [
|
"exclude": ["node_modules"]
|
||||||
"node_modules",
|
|
||||||
"jest.config.ts",
|
|
||||||
"src/**/*.spec.ts",
|
|
||||||
"src/**/*.test.ts"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,7 @@
|
|||||||
{
|
{
|
||||||
"extends": [
|
"extends": [
|
||||||
"plugin:@nrwl/nx/react-typescript",
|
|
||||||
"next",
|
"next",
|
||||||
"next/core-web-vitals",
|
"next/core-web-vitals"
|
||||||
"../../.eslintrc.json"
|
|
||||||
],
|
],
|
||||||
"ignorePatterns": ["!**/*", ".next/**/*"],
|
"ignorePatterns": ["!**/*", ".next/**/*"],
|
||||||
"overrides": [
|
"overrides": [
|
||||||
|
|||||||
@ -1,25 +1,13 @@
|
|||||||
This is a repo intended to serve as a simple example of a data catalog that get its data from a series of github repos, you can init an example just like this one by.
|
This is a repo intended to serve as a simple example of a data catalog that get its data from a series of github repos, you can init an example just like this one by.
|
||||||
|
|
||||||
- Cloning the PortalJS repo on your machine
|
- Creating a new project with `create-next-app` like so:
|
||||||
|
|
||||||
```
|
```
|
||||||
git clone https://github.com/datopian/portaljs.git
|
npx create-next-app <app-name> --example https://github.com/datopian/portaljs/tree/main/examples/simple-example
|
||||||
|
cd <app-name>
|
||||||
```
|
```
|
||||||
|
|
||||||
- Creating a new file inside the `examples` folder with `create-next-app` like so:
|
- This project uses the github api, which for anonymous users will cap at 50 requests per hour, so you might want to get a [Personal Access Token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) and add it to a `.env` file inside the folder like so
|
||||||
|
|
||||||
```
|
|
||||||
npx create-next-app <app-name> --example https://github.com/datopian/portaljs/tree/main/ --example-path examples/simple-example
|
|
||||||
```
|
|
||||||
|
|
||||||
- Inside `<app-name>` go to the `project.json` file and replace all instances of `simple-example` with `<app-name>`
|
|
||||||
- Create a `.env` file with the following content
|
|
||||||
|
|
||||||
```
|
|
||||||
PROJECT_NAME=<app-name>
|
|
||||||
```
|
|
||||||
|
|
||||||
- This project uses the github api, which for anonymous users will cap at 50 requests per hour, so you might want to get a [Personal Access Token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) and add it to your .env file like so
|
|
||||||
|
|
||||||
```
|
```
|
||||||
GITHUB_PAT=<github token>
|
GITHUB_PAT=<github token>
|
||||||
@ -29,14 +17,20 @@ GITHUB_PAT=<github token>
|
|||||||
- Run the app using:
|
- Run the app using:
|
||||||
|
|
||||||
```
|
```
|
||||||
nx serve <app-name>
|
npm run dev
|
||||||
```
|
```
|
||||||
|
|
||||||
Congratulations, you now have something similar to this running on `http://localhost:4200`
|
Congratulations, you now have something similar to this running on `http://localhost:3000`
|
||||||

|

|
||||||
If yo go to any one of those pages by clicking on `More info` you will see something similar to this
|
If yo go to any one of those pages by clicking on `More info` you will see something similar to this
|
||||||

|

|
||||||
|
|
||||||
|
## Deployment
|
||||||
|
|
||||||
|
[](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fdatopian%2Fportaljs%2Ftree%2Fmain%2Fexamples%2Fsimple-example)
|
||||||
|
|
||||||
|
By clicking on this button, you will be redirected to a page which will allow you to clone the content into your own github/gitlab/bitbucket account and automatically deploy everything.
|
||||||
|
|
||||||
|
|
||||||
## Structure of `datasets.json`
|
## Structure of `datasets.json`
|
||||||
|
|
||||||
@ -64,3 +58,18 @@ You can also add
|
|||||||
|
|
||||||
- A `description` which is useful if you have more than one dataset for each repo, if not provided we are just going to use the repo description
|
- A `description` which is useful if you have more than one dataset for each repo, if not provided we are just going to use the repo description
|
||||||
- A `Name` which is useful if you want to give your dataset a nice name, if not provided we are going to use the junction of the `owner` the `repo` + the path of the README, in the exaple above it will be `fivethirtyeight/data/nba-raptor`
|
- A `Name` which is useful if you want to give your dataset a nice name, if not provided we are going to use the junction of the `owner` the `repo` + the path of the README, in the exaple above it will be `fivethirtyeight/data/nba-raptor`
|
||||||
|
|
||||||
|
## Extra commands
|
||||||
|
|
||||||
|
You can also build the project for production with
|
||||||
|
|
||||||
|
```
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
And run using the production build like so:
|
||||||
|
|
||||||
|
```
|
||||||
|
npm run start
|
||||||
|
```
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
export default {
|
|
||||||
displayName: 'simple-example',
|
|
||||||
preset: '../../jest.preset.js',
|
|
||||||
transform: {
|
|
||||||
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nrwl/react/plugins/jest',
|
|
||||||
'^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nrwl/next/babel'] }],
|
|
||||||
},
|
|
||||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
|
|
||||||
coverageDirectory: '../../coverage/examples/simple-example',
|
|
||||||
};
|
|
||||||
@ -1,9 +1,3 @@
|
|||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
||||||
const { withNx } = require('@nrwl/next/plugins/with-nx');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {import('@nrwl/next/plugins/with-nx').WithNxOptions}
|
|
||||||
**/
|
|
||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
async rewrites() {
|
async rewrites() {
|
||||||
return {
|
return {
|
||||||
@ -17,13 +11,7 @@ const nextConfig = {
|
|||||||
},
|
},
|
||||||
serverRuntimeConfig: {
|
serverRuntimeConfig: {
|
||||||
github_pat: process.env.GITHUB_PAT ? process.env.GITHUB_PAT : null,
|
github_pat: process.env.GITHUB_PAT ? process.env.GITHUB_PAT : null,
|
||||||
project_name: process.env.PROJECT_NAME ? process.env.PROJECT_NAME : 'simple-example'
|
|
||||||
},
|
|
||||||
nx: {
|
|
||||||
// Set this to true if you would like to use SVGR
|
|
||||||
// See: https://github.com/gregberge/svgr
|
|
||||||
svgr: true,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = withNx(nextConfig);
|
module.exports = nextConfig;
|
||||||
|
|||||||
5833
examples/simple-example/package-lock.json
generated
Normal file
5833
examples/simple-example/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,32 @@
|
|||||||
{
|
{
|
||||||
"name": "simple-example",
|
"name": "my-app",
|
||||||
"version": "1.0.0",
|
"version": "0.1.0",
|
||||||
"description": "",
|
"private": true,
|
||||||
"author": "",
|
"scripts": {
|
||||||
"license": "ISC"
|
"dev": "next dev",
|
||||||
|
"build": "next build",
|
||||||
|
"start": "next start",
|
||||||
|
"lint": "next lint"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@types/node": "18.16.0",
|
||||||
|
"@types/react": "18.0.38",
|
||||||
|
"@types/react-dom": "18.0.11",
|
||||||
|
"eslint": "8.39.0",
|
||||||
|
"eslint-config-next": "13.3.1",
|
||||||
|
"next": "13.3.1",
|
||||||
|
"next-seo": "^6.0.0",
|
||||||
|
"octokit": "^2.0.14",
|
||||||
|
"react": "18.2.0",
|
||||||
|
"react-dom": "18.2.0",
|
||||||
|
"react-markdown": "^8.0.7",
|
||||||
|
"remark-gfm": "^3.0.1",
|
||||||
|
"typescript": "5.0.4"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@tailwindcss/typography": "^0.5.9",
|
||||||
|
"autoprefixer": "^10.4.14",
|
||||||
|
"postcss": "^8.4.23",
|
||||||
|
"tailwindcss": "^3.3.1"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,10 +61,9 @@ export default function ProjectPage({ project }) {
|
|||||||
|
|
||||||
// Generates `/posts/1` and `/posts/2`
|
// Generates `/posts/1` and `/posts/2`
|
||||||
export async function getStaticPaths() {
|
export async function getStaticPaths() {
|
||||||
const project_name = getConfig().serverRuntimeConfig.project_name;
|
|
||||||
const jsonDirectory = path.join(
|
const jsonDirectory = path.join(
|
||||||
process.cwd(),
|
process.cwd(),
|
||||||
`/examples/${project_name}/datasets.json`
|
'datasets.json'
|
||||||
);
|
);
|
||||||
const repos = await fs.readFile(jsonDirectory, 'utf8');
|
const repos = await fs.readFile(jsonDirectory, 'utf8');
|
||||||
|
|
||||||
@ -89,10 +88,9 @@ export async function getStaticPaths() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getStaticProps({ params }) {
|
export async function getStaticProps({ params }) {
|
||||||
const project_name = getConfig().serverRuntimeConfig.project_name;
|
|
||||||
const jsonDirectory = path.join(
|
const jsonDirectory = path.join(
|
||||||
process.cwd(),
|
process.cwd(),
|
||||||
`/examples/${project_name}/datasets.json`
|
'datasets.json'
|
||||||
);
|
);
|
||||||
const reposFile = await fs.readFile(jsonDirectory, 'utf8');
|
const reposFile = await fs.readFile(jsonDirectory, 'utf8');
|
||||||
const repos: GithubProject[] = JSON.parse(reposFile);
|
const repos: GithubProject[] = JSON.parse(reposFile);
|
||||||
|
|||||||
@ -4,10 +4,9 @@ import { getProject } from '../lib/octokit';
|
|||||||
import getConfig from 'next/config';
|
import getConfig from 'next/config';
|
||||||
|
|
||||||
export async function getStaticProps() {
|
export async function getStaticProps() {
|
||||||
const project_name = getConfig().serverRuntimeConfig.project_name;
|
|
||||||
const jsonDirectory = path.join(
|
const jsonDirectory = path.join(
|
||||||
process.cwd(),
|
process.cwd(),
|
||||||
`/examples/${project_name}/datasets.json`
|
'/datasets.json'
|
||||||
);
|
);
|
||||||
const repos = await fs.readFile(jsonDirectory, 'utf8');
|
const repos = await fs.readFile(jsonDirectory, 'utf8');
|
||||||
const github_pat = getConfig().serverRuntimeConfig.github_pat;
|
const github_pat = getConfig().serverRuntimeConfig.github_pat;
|
||||||
@ -83,7 +82,7 @@ export function Datasets({ projects }) {
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody className="divide-y divide-gray-200">
|
<tbody className="divide-y divide-gray-200">
|
||||||
{projects.map((project) => (
|
{projects.map((project) => (
|
||||||
<tr>
|
<tr key={project.id}>
|
||||||
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
|
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
|
||||||
{project.repo_config.name
|
{project.repo_config.name
|
||||||
? project.repo_config.name
|
? project.repo_config.name
|
||||||
|
|||||||
@ -1,15 +1,6 @@
|
|||||||
const { join } = require('path');
|
|
||||||
|
|
||||||
// Note: If you use library-specific PostCSS/Tailwind configuration then you should remove the `postcssConfig` build
|
|
||||||
// option from your application's configuration (i.e. project.json).
|
|
||||||
//
|
|
||||||
// See: https://nx.dev/guides/using-tailwind-css-in-react#step-4:-applying-configuration-to-libraries
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
plugins: {
|
plugins: {
|
||||||
tailwindcss: {
|
tailwindcss: {},
|
||||||
config: join(__dirname, 'tailwind.config.js'),
|
|
||||||
},
|
|
||||||
autoprefixer: {},
|
autoprefixer: {},
|
||||||
},
|
},
|
||||||
};
|
}
|
||||||
|
|||||||
@ -1,69 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "simple-example",
|
|
||||||
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
||||||
"sourceRoot": "examples/simple-example",
|
|
||||||
"projectType": "application",
|
|
||||||
"targets": {
|
|
||||||
"build": {
|
|
||||||
"executor": "@nrwl/next:build",
|
|
||||||
"outputs": ["{options.outputPath}"],
|
|
||||||
"defaultConfiguration": "production",
|
|
||||||
"options": {
|
|
||||||
"root": "examples/simple-example",
|
|
||||||
"outputPath": "dist/examples/simple-example"
|
|
||||||
},
|
|
||||||
"configurations": {
|
|
||||||
"development": {
|
|
||||||
"outputPath": "examples/simple-example"
|
|
||||||
},
|
|
||||||
"production": {}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"serve": {
|
|
||||||
"executor": "@nrwl/next:server",
|
|
||||||
"defaultConfiguration": "development",
|
|
||||||
"options": {
|
|
||||||
"buildTarget": "simple-example:build",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"configurations": {
|
|
||||||
"development": {
|
|
||||||
"buildTarget": "simple-example:build:development",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"production": {
|
|
||||||
"buildTarget": "simple-example:build:production",
|
|
||||||
"dev": false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"export": {
|
|
||||||
"executor": "@nrwl/next:export",
|
|
||||||
"options": {
|
|
||||||
"buildTarget": "simple-example:build:production"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"test": {
|
|
||||||
"executor": "@nrwl/jest:jest",
|
|
||||||
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
|
|
||||||
"options": {
|
|
||||||
"jestConfig": "examples/simple-example/jest.config.ts",
|
|
||||||
"passWithNoTests": true
|
|
||||||
},
|
|
||||||
"configurations": {
|
|
||||||
"ci": {
|
|
||||||
"ci": true,
|
|
||||||
"codeCoverage": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"lint": {
|
|
||||||
"executor": "@nrwl/linter:eslint",
|
|
||||||
"outputs": ["{options.outputFile}"],
|
|
||||||
"options": {
|
|
||||||
"lintFilePatterns": ["examples/simple-example/**/*.{ts,tsx,js,jsx}"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"tags": []
|
|
||||||
}
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import { render } from '@testing-library/react';
|
|
||||||
|
|
||||||
import Index from '../pages/index';
|
|
||||||
|
|
||||||
describe('Index', () => {
|
|
||||||
it('should render successfully', () => {
|
|
||||||
const { baseElement } = render(<Index />);
|
|
||||||
expect(baseElement).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -1,21 +1,15 @@
|
|||||||
const { createGlobPatternsForDependencies } = require('@nrwl/react/tailwind');
|
|
||||||
const { join } = require('path');
|
|
||||||
|
|
||||||
/** @type {import('tailwindcss').Config} */
|
/** @type {import('tailwindcss').Config} */
|
||||||
module.exports = {
|
module.exports = {
|
||||||
content: [
|
content: [
|
||||||
"node_modules/@flowershow/core/dist/*.js",
|
"./app/**/*.{js,ts,jsx,tsx,mdx}",
|
||||||
"node_modules/@flowershow/core/*.js",
|
"./pages/**/*.{js,ts,jsx,tsx,mdx}",
|
||||||
join(
|
"./components/**/*.{js,ts,jsx,tsx,mdx}",
|
||||||
__dirname,
|
|
||||||
'{src,pages,components}/**/*!(*.stories|*.spec).{ts,tsx,html}'
|
|
||||||
),
|
|
||||||
...createGlobPatternsForDependencies(__dirname),
|
|
||||||
],
|
],
|
||||||
theme: {
|
theme: {
|
||||||
extend: {},
|
extend: {},
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
require('@tailwindcss/typography'),
|
require('@tailwindcss/typography')
|
||||||
],
|
],
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,50 +1,20 @@
|
|||||||
{
|
{
|
||||||
"extends": "../../tsconfig.base.json",
|
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"jsx": "preserve",
|
"target": "es5",
|
||||||
|
"lib": ["dom", "dom.iterable", "esnext"],
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"esModuleInterop": true,
|
"skipLibCheck": true,
|
||||||
"allowSyntheticDefaultImports": true,
|
|
||||||
"strict": false,
|
"strict": false,
|
||||||
"forceConsistentCasingInFileNames": true,
|
"forceConsistentCasingInFileNames": true,
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"module": "esnext",
|
||||||
|
"moduleResolution": "node",
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"isolatedModules": true,
|
"isolatedModules": true,
|
||||||
"incremental": true,
|
"jsx": "preserve",
|
||||||
"types": [
|
"incremental": true
|
||||||
"jest",
|
|
||||||
"node"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"target": "es2020",
|
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
|
||||||
"lib": [
|
"exclude": ["node_modules"]
|
||||||
"dom",
|
|
||||||
"dom.iterable",
|
|
||||||
"esnext"
|
|
||||||
],
|
|
||||||
"allowJs": true,
|
|
||||||
"skipLibCheck": true,
|
|
||||||
"strict": false,
|
|
||||||
"forceConsistentCasingInFileNames": true,
|
|
||||||
"noEmit": true,
|
|
||||||
"incremental": true,
|
|
||||||
"esModuleInterop": true,
|
|
||||||
"module": "esnext",
|
|
||||||
"moduleResolution": "node",
|
|
||||||
"resolveJsonModule": true,
|
|
||||||
"isolatedModules": true,
|
|
||||||
"jsx": "preserve",
|
|
||||||
"include": [
|
|
||||||
"**/*.ts",
|
|
||||||
"**/*.tsx",
|
|
||||||
"**/*.js",
|
|
||||||
"**/*.jsx",
|
|
||||||
"next-env.d.ts"
|
|
||||||
],
|
|
||||||
"exclude": [
|
|
||||||
"node_modules",
|
|
||||||
"jest.config.ts",
|
|
||||||
"src/**/*.spec.ts",
|
|
||||||
"src/**/*.test.ts"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,24 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": "./tsconfig.json",
|
|
||||||
"compilerOptions": {
|
|
||||||
"outDir": "../../dist/out-tsc",
|
|
||||||
"module": "commonjs",
|
|
||||||
"types": ["jest", "node"],
|
|
||||||
"jsx": "react"
|
|
||||||
},
|
|
||||||
"paths": {
|
|
||||||
"@/*": ["./*"]
|
|
||||||
},
|
|
||||||
"include": [
|
|
||||||
"jest.config.ts",
|
|
||||||
"src/**/*.test.ts",
|
|
||||||
"src/**/*.spec.ts",
|
|
||||||
"src/**/*.test.tsx",
|
|
||||||
"src/**/*.spec.tsx",
|
|
||||||
"src/**/*.test.js",
|
|
||||||
"src/**/*.spec.js",
|
|
||||||
"src/**/*.test.jsx",
|
|
||||||
"src/**/*.spec.jsx",
|
|
||||||
"src/**/*.d.ts"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
61
package.json
61
package.json
@ -4,63 +4,7 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {},
|
"scripts": {},
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {},
|
||||||
"@apollo/client": "^3.7.11",
|
|
||||||
"@apollo/react-hooks": "^4.0.0",
|
|
||||||
"@emotion/react": "^11.10.6",
|
|
||||||
"@emotion/styled": "^11.10.6",
|
|
||||||
"@flowershow/core": "^0.4.9",
|
|
||||||
"@flowershow/markdowndb": "^0.1.0",
|
|
||||||
"@flowershow/remark-callouts": "^1.0.0",
|
|
||||||
"@flowershow/remark-embed": "^1.0.0",
|
|
||||||
"@flowershow/remark-wiki-link": "^1.0.1",
|
|
||||||
"@headlessui/react": "^1.7.13",
|
|
||||||
"@heroicons/react": "^2.0.17",
|
|
||||||
"@mui/icons-material": "^5.11.16",
|
|
||||||
"@mui/material": "^5.11.16",
|
|
||||||
"@mui/x-data-grid": "^6.1.0",
|
|
||||||
"@opentelemetry/api": "^1.4.0",
|
|
||||||
"@tailwindcss/typography": "^0.5.9",
|
|
||||||
"@tanstack/react-table": "^8.8.5",
|
|
||||||
"apollo-cache-inmemory": "^1.6.6",
|
|
||||||
"apollo-link": "^1.2.14",
|
|
||||||
"apollo-link-rest": "^0.9.0",
|
|
||||||
"filesize": "^10.0.7",
|
|
||||||
"gray-matter": "^4.0.3",
|
|
||||||
"html-react-parser": "^3.0.15",
|
|
||||||
"markdown-it": "^13.0.1",
|
|
||||||
"next": "^13.2.1",
|
|
||||||
"next-mdx-remote": "^4.4.1",
|
|
||||||
"next-seo": "^6.0.0",
|
|
||||||
"next-translate": "^2.0.5",
|
|
||||||
"nock": "^13.3.0",
|
|
||||||
"octokit": "^2.0.14",
|
|
||||||
"papaparse": "^5.4.1",
|
|
||||||
"plotly.js-basic-dist": "^2.20.0",
|
|
||||||
"prop-types": "^15.8.1",
|
|
||||||
"react": "18.2.0",
|
|
||||||
"react-dom": "18.2.0",
|
|
||||||
"react-markdown": "^8.0.7",
|
|
||||||
"react-next-github-btn": "^1.2.1",
|
|
||||||
"react-plotly.js": "^2.6.0",
|
|
||||||
"react-plotlyjs": "^0.4.4",
|
|
||||||
"react-vega": "^7.6.0",
|
|
||||||
"rehype-autolink-headings": "^6.1.1",
|
|
||||||
"rehype-katex": "^6.0.2",
|
|
||||||
"rehype-prism-plus": "^1.5.1",
|
|
||||||
"rehype-slug": "^5.1.0",
|
|
||||||
"remark-footnotes": "^4.0.1",
|
|
||||||
"remark-gfm": "^3.0.1",
|
|
||||||
"remark-math": "^5.1.1",
|
|
||||||
"remark-slug": "^7.0.1",
|
|
||||||
"remark-smartypants": "^2.0.0",
|
|
||||||
"remark-toc": "^8.0.1",
|
|
||||||
"slugify": "^1.6.6",
|
|
||||||
"timeago.js": "^4.0.2",
|
|
||||||
"tslib": "^2.3.0",
|
|
||||||
"vega": "^5.24.0",
|
|
||||||
"xlsx": "^0.18.5"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/preset-react": "^7.14.5",
|
"@babel/preset-react": "^7.14.5",
|
||||||
"@nrwl/cypress": "15.9.2",
|
"@nrwl/cypress": "15.9.2",
|
||||||
@ -84,7 +28,6 @@
|
|||||||
"@types/react-dom": "18.0.11",
|
"@types/react-dom": "18.0.11",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.36.1",
|
"@typescript-eslint/eslint-plugin": "^5.36.1",
|
||||||
"@typescript-eslint/parser": "^5.36.1",
|
"@typescript-eslint/parser": "^5.36.1",
|
||||||
"autoprefixer": "10.4.13",
|
|
||||||
"babel-jest": "^29.4.1",
|
"babel-jest": "^29.4.1",
|
||||||
"cypress": "^12.2.0",
|
"cypress": "^12.2.0",
|
||||||
"eslint": "~8.15.0",
|
"eslint": "~8.15.0",
|
||||||
@ -98,11 +41,9 @@
|
|||||||
"jest": "^29.4.1",
|
"jest": "^29.4.1",
|
||||||
"jest-environment-jsdom": "^29.4.1",
|
"jest-environment-jsdom": "^29.4.1",
|
||||||
"nx": "15.9.2",
|
"nx": "15.9.2",
|
||||||
"postcss": "8.4.21",
|
|
||||||
"prettier": "^2.6.2",
|
"prettier": "^2.6.2",
|
||||||
"react-test-renderer": "18.2.0",
|
"react-test-renderer": "18.2.0",
|
||||||
"swc-loader": "0.1.15",
|
"swc-loader": "0.1.15",
|
||||||
"tailwindcss": "3.2.7",
|
|
||||||
"ts-jest": "^29.0.5",
|
"ts-jest": "^29.0.5",
|
||||||
"ts-node": "10.9.1",
|
"ts-node": "10.9.1",
|
||||||
"typescript": "~4.9.5"
|
"typescript": "~4.9.5"
|
||||||
|
|||||||
@ -8,19 +8,47 @@ date: 2023-04-20
|
|||||||
|
|
||||||
This is a repo intended to serve as an example of a data catalog that get its data from a CKAN Instance.
|
This is a repo intended to serve as an example of a data catalog that get its data from a CKAN Instance.
|
||||||
|
|
||||||
- Creating a new file inside o `examples` with `create-next-app` like so:
|
|
||||||
```
|
```
|
||||||
npx create-next-app <app-name> --example https://github.com/datopian/portaljs/tree/main/ --example-path examples/ckan-example
|
npx create-next-app <app-name> --example https://github.com/datopian/portaljs/tree/main/examples/ckan-example
|
||||||
|
cd <app-name>
|
||||||
```
|
```
|
||||||
- Inside `<app-name>` go to the `project.json` file and replace all instances of `ckan-example` with `<app-name>`
|
|
||||||
- Set the `DMS` env variable to the Url of the CKAN Instance Ex: `export DMS=https://demo.dev.datopian.com`
|
- This project uses CKAN as a backend, so you need to point the project to the CKAN Url desired, you can do so by setting up the `DMS` env variable in your terminal or adding a `.env` file with the following content:
|
||||||
|
|
||||||
|
```
|
||||||
|
DMS=<ckan url>
|
||||||
|
```
|
||||||
|
|
||||||
- Run the app using:
|
- Run the app using:
|
||||||
|
|
||||||
```
|
```
|
||||||
nx serve <app-name>
|
npm run dev
|
||||||
```
|
```
|
||||||
|
|
||||||
Congratulations, you now have something similar to this running on `http://localhost:4200`
|
Congratulations, you now have something similar to this running on `http://localhost:4200`
|
||||||

|

|
||||||
|
|
||||||
If yo go to any one of those pages by clicking on `More info` you will see something similar to this
|
If yo go to any one of those pages by clicking on `More info` you will see something similar to this
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
## Deployment
|
||||||
|
|
||||||
|
[](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fdatopian%2Fportaljs%2Ftree%2Fmain%2Fexamples%2Fckan-example&env=DMS&envDescription=URL%20For%20the%20CKAN%20Backend%20Ex%3A%20https%3A%2F%2Fdemo.dev.datopian.com)
|
||||||
|
|
||||||
|
By clicking on this button, you will be redirected to a page which will allow you to clone the content into your own github/gitlab/bitbucket account and automatically deploy everything.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Extra commands
|
||||||
|
|
||||||
|
You can also build the project for production with
|
||||||
|
|
||||||
|
```
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
And run using the production build like so:
|
||||||
|
|
||||||
|
```
|
||||||
|
npm run start
|
||||||
|
```
|
||||||
|
|
||||||
|
|||||||
@ -6,22 +6,76 @@ date: 2023-04-20
|
|||||||
|
|
||||||
**See the repo:** https://github.com/datopian/portaljs/tree/main/examples/simple-example
|
**See the repo:** https://github.com/datopian/portaljs/tree/main/examples/simple-example
|
||||||
|
|
||||||
This is a repo intended to serve as a simple example of a data catalog that get its data from a series of github repos, you can init an example just like this one by.
|
- Creating a new project with `create-next-app` like so:
|
||||||
|
|
||||||
- Creating a new file inside of `examples` with `create-next-app` like so:
|
|
||||||
```
|
```
|
||||||
npx create-next-app <app-name> --example https://github.com/datopian/portaljs/tree/main/ --example-path examples/simple-example
|
npx create-next-app <app-name> --example https://github.com/datopian/portaljs/tree/main/examples/simple-example
|
||||||
|
cd <app-name>
|
||||||
```
|
```
|
||||||
- Inside `<app-name>` go to the `project.json` file and replace all instances of `simple-example` with `<app-name>`
|
|
||||||
|
- This project uses the github api, which for anonymous users will cap at 50 requests per hour, so you might want to get a [Personal Access Token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) and add it to a `.env` file inside the folder like so
|
||||||
|
|
||||||
|
```
|
||||||
|
GITHUB_PAT=<github token>
|
||||||
|
```
|
||||||
|
|
||||||
- Edit the file `datasets.json` to your liking, some examples can be found inside this [repo](https://github.com/datasets)
|
- Edit the file `datasets.json` to your liking, some examples can be found inside this [repo](https://github.com/datasets)
|
||||||
- Run the app using:
|
- Run the app using:
|
||||||
|
|
||||||
```
|
```
|
||||||
nx serve <app-name>
|
npm run dev
|
||||||
```
|
```
|
||||||
|
|
||||||
Congratulations, you now have something similar to this running on `http://localhost:4200`
|
Congratulations, you now have something similar to this running on `http://localhost:3000`
|
||||||

|

|
||||||
|
|
||||||
If yo go to any one of those pages by clicking on `More info` you will see something similar to this
|
If yo go to any one of those pages by clicking on `More info` you will see something similar to this
|
||||||
|

|
||||||
|
|
||||||
|
## Deployment
|
||||||
|
|
||||||
|
[](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fdatopian%2Fportaljs%2Ftree%2Fmain%2Fexamples%2Fsimple-example)
|
||||||
|
|
||||||
|
By clicking on this button, you will be redirected to a page which will allow you to clone the content into your own github/gitlab/bitbucket account and automatically deploy everything.
|
||||||
|
|
||||||
|
|
||||||
|
## Structure of `datasets.json`
|
||||||
|
|
||||||
|
The `datasets.json` file is simply a list of datasets, below you can see a minimal example of a dataset
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"owner": "fivethirtyeight",
|
||||||
|
"repo": "data",
|
||||||
|
"branch": "master",
|
||||||
|
"files": ["nba-raptor/historical_RAPTOR_by_player.csv", "nba-raptor/historical_RAPTOR_by_team.csv"],
|
||||||
|
"readme": "nba-raptor/README.md"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
It has
|
||||||
|
|
||||||
|
- A `owner` which is going to be the github repo owner
|
||||||
|
- A `repo` which is going to be the github repo name
|
||||||
|
- A `branch` which is going to be the branch to which we need to get the files and the readme
|
||||||
|
- A list of `files` which is going to be a list of paths with files that you want to show to the world
|
||||||
|
- A `readme` which is going to be the path to your data description, it can also be a subpath eg: `example/README.md`
|
||||||
|
|
||||||
|
You can also add
|
||||||
|
|
||||||
|
- A `description` which is useful if you have more than one dataset for each repo, if not provided we are just going to use the repo description
|
||||||
|
- A `Name` which is useful if you want to give your dataset a nice name, if not provided we are going to use the junction of the `owner` the `repo` + the path of the README, in the exaple above it will be `fivethirtyeight/data/nba-raptor`
|
||||||
|
|
||||||
|
## Extra commands
|
||||||
|
|
||||||
|
You can also build the project for production with
|
||||||
|
|
||||||
|
```
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
And run using the production build like so:
|
||||||
|
|
||||||
|
```
|
||||||
|
npm run start
|
||||||
|
```
|
||||||
|
|
||||||

|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user