Skip to content

Commit

Permalink
Remove react (#824)
Browse files Browse the repository at this point in the history
* convert to no react

* wip

* proper oss/nonoss fix

* more progress

* wip

* more progress

* fixes

* even more fixes

* even more fixes

* more fixes

* eslint added

* fixes

* fixes

* fixes

* fix annoying issues

* issues with export functions fixed

* properly embed data

* debug netlify

* fixes

* fix

* debug

* forgot async

* more fixes

* minor fixes

* do not forget eslint

Co-authored-by: Andrey Kozlov <zeus@Andreys-MacBook-Pro.local>
  • Loading branch information
AndreyKozlov1984 and Andrey Kozlov authored Jun 3, 2022
1 parent ebb53fe commit 84749ce
Show file tree
Hide file tree
Showing 141 changed files with 2,440 additions and 4,052 deletions.
16 changes: 0 additions & 16 deletions .babelrc.js

This file was deleted.

1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
netlify/jsyaml.js
19 changes: 19 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
"extends": "eslint:recommended",
"root": true,
"env": {
"browser": true,
"commonjs": true,
"es2021": true,
"node": true
},
"parserOptions": {
"ecmaVersion": "latest"
},
"rules": {
"no-useless-escape": 0,
"no-prototype-builtins": 0,
"no-empty": 0,
"no-control-regex": 0
}
}
2 changes: 1 addition & 1 deletion landscapes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ nvm use
npm install -g npm
npm install -g yarn
yarn
yarn run babel-node tools/landscapes.js
yarn node tools/landscapes.js
5 changes: 2 additions & 3 deletions netlify/landscape.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const runLocal = function(command, options = {}) {
console.info(lastOutput.s);
lastOutput.s = "";
lastOutput.time = new Date().getTime();
};
}
}
}

Expand Down Expand Up @@ -299,15 +299,14 @@ const makeRemoteBuildWithCache = async function() {
}

async function main() {
const path = require('path');
console.info('starting', process.cwd());
process.chdir('..');
await runLocal('rm package*.json');

const cleanPromise = runRemoteWithoutErrors(`
find builds/node_cache -maxdepth 1 -mtime +1 -exec rm -rf {} +;
find builds/ -maxdepth 1 -not -path "builds/node_cache" -mtime +1 -exec rm -rf {} +;
`).catch(function(ex) {
`).catch(function() {
console.info('Failed to clean up a builds folder');
});

Expand Down
8 changes: 3 additions & 5 deletions netlify/landscapeapp.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
const path = require('path')
const { readdirSync, writeFileSync } = require('fs')
const generateIndex = require('./generateIndex')
const run = function(x) {
console.info(require('child_process').execSync(x).toString())
}
const debug = function() {
if (process.env.DEBUG_BUILD) {
console.info.apply(console, arguments);
Expand Down Expand Up @@ -167,7 +164,6 @@ EOSSH
await runRemoteWithoutErrors(`chmod -R 777 /root/builds/${folder}`);

// lets guarantee npm install for this folder first
const branch = process.env.BRANCH;
{
const buildCommand = [
"(ls . ~/.nvm/nvm.sh || (curl -s -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash >/dev/null))",
Expand All @@ -176,7 +172,8 @@ EOSSH
`nvm use ${nvmrc}`,
`npm install -g yarn --no-progress --silent`,
`cd /opt/repo`,
`yarn >/dev/null`
`yarn >/dev/null`,
`yarn eslint`
].join(' && ');
const npmInstallCommand = `
mkdir -p /root/builds/${folder}_node
Expand Down Expand Up @@ -207,6 +204,7 @@ EOSSH
const outputFolder = landscape.name + new Date().getTime();
const buildCommand = [
`cd /opt/repo`,
`git config --global --add safe.directory /opt/repo`,
`. ~/.nvm/nvm.sh`,
`nvm use`,
`export NODE_OPTIONS="--unhandled-rejections=strict"`,
Expand Down
63 changes: 21 additions & 42 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,62 +7,51 @@
"node": ">= 10.5"
},
"scripts": {
"autocrop-images": "babel-node tools/autocropImages",
"eslint": "eslint src tools specs netlify",
"autocrop-images": "node tools/autocropImages",
"dev": "yarn server",
"open:src": "yarn server",
"server": "babel-node server.js",
"landscapes": "babel-node tools/landscapes.js",
"server": "node server.js",
"landscapes": "node tools/landscapes.js",
"update-github-colors": "curl https://raw.githubusercontent.com/Diastro/github-colors/master/github-colors.json > tools/githubColors.json",
"fetch": "babel-node tools/validateLandscape && babel-node tools/checkWrongCharactersInFilenames && babel-node tools/addExternalInfo.js && yarn yaml2json",
"fetch": "node tools/validateLandscape && node tools/checkWrongCharactersInFilenames && node tools/addExternalInfo.js && yarn yaml2json",
"fetchAll": "LEVEL=complete yarn fetch",
"update": "(rm /tmp/landscape.json || true) && babel-node tools/validateLandscape && yarn remove-quotes && LEVEL=medium babel-node tools/addExternalInfo.js && yarn prune && yarn check-links && yarn yaml2json && babel-node tools/calculateNumberOfTweets && babel-node tools/updateTimestamps",
"yaml2json": "babel-node tools/generateJson.js",
"remove-quotes": "babel-node tools/removeQuotes",
"prune": "babel-node tools/pruneExtraEntries",
"check-links": "babel-node tools/checkLinks",
"remove-dist": "rimraf \"$PROJECT_PATH\"/dist",
"update": "(rm /tmp/landscape.json || true) && node tools/validateLandscape && yarn remove-quotes && LEVEL=medium node tools/addExternalInfo.js && yarn prune && yarn check-links && yarn yaml2json && node tools/calculateNumberOfTweets && node tools/updateTimestamps",
"yaml2json": "node tools/generateJson.js",
"remove-quotes": "node tools/removeQuotes",
"prune": "node tools/pruneExtraEntries",
"check-links": "node tools/checkLinks",
"precommit": "yarn fetch",
"start-ci": "yarn exec bash -c \"(yarn run babel-node tools/distServer.js &) && sleep 10\"",
"stop-old-ci": "yarn run babel-node tools/stopOldDistServer.js",
"start-ci": "yarn exec bash -c \"(node tools/distServer.js &) && sleep 10\"",
"stop-old-ci": "node tools/stopOldDistServer.js",
"stop-ci": "yarn exec bash -c \"kill -9 `cat /tmp/ci.pid` >/dev/null 2>/dev/null && rm /tmp/ci.pid \"",
"integration-test": "jest --runInBand --reporters=jest-standard-reporter",
"test": "jest",
"check-landscape": "babel-node tools/checkLandscape",
"render-landscape": "babel-node tools/renderLandscape",
"funding": "babel-node tools/fundingForMasterBranch",
"prepare-landscape": "babel-node tools/prepareLandscape.js && babel-node tools/renderItems.js",
"setup-robots": "babel-node tools/sitemap && babel-node tools/addRobots",
"build": "yarn fetch && yarn prepare-landscape && babel-node tools/renderAcquisitions && yarn setup-robots && yarn export-functions && yarn stop-old-ci && yarn start-ci && babel-node tools/parallelWithRetry integration-test check-landscape render-landscape funding && yarn stop-ci",
"export-functions": "babel-node ./tools/exportFunctions",
"check-landscape": "node tools/checkLandscape",
"render-landscape": "node tools/renderLandscape",
"funding": "node tools/fundingForMasterBranch",
"prepare-landscape": "node tools/prepareLandscape.js && node tools/renderItems.js",
"setup-robots": "node tools/sitemap && node tools/addRobots",
"build": "yarn fetch && yarn prepare-landscape && node tools/renderAcquisitions && yarn setup-robots && yarn export-functions && yarn stop-old-ci && yarn start-ci && node tools/parallelWithRetry integration-test check-landscape render-landscape funding && yarn stop-ci",
"export-functions": "node ./tools/exportFunctions",
"latest": "yarn",
"reset-tweet-count": "babel-node tools/resetTweetCount.js",
"reset-tweet-count": "node tools/resetTweetCount.js",
"prepublish": "cp yarn.lock _yarn.lock",
"postpublish": "rm _yarn.lock || true",
"preview": "yarn fetch && yarn prepare-landscape && yarn export-functions"
},
"author": "CNCF",
"license": "Apache-2.0",
"dependencies": {
"@babel/core": "^7.17.10",
"@babel/node": "^7.17.10",
"@babel/plugin-transform-react-jsx": "^7.17.3",
"@babel/plugin-transform-runtime": "^7.17.10",
"@babel/preset-env": "^7.17.10",
"@babel/register": "^7.17.7",
"@babel/runtime": "^7.17.9",
"@vercel/ncc": "^0.33.4",
"anchorme": "^2.1.2",
"axe-puppeteer": "^1.1.1",
"axios": "^0.27.2",
"babel-plugin-module-resolver": "^4.1.0",
"bluebird": "3.7.2",
"change-case": "^4.1.2",
"cheerio": "^1.0.0-rc.10",
"chokidar": "^3.5.3",
"classnames": "^2.3.1",
"colors": "1.4.0",
"compression": "^1.7.4",
"debug": "^4.3.4",
"eslint": "latest",
"event-emitter": "0.3.5",
"expect-puppeteer": "^6.1.0",
"feed": "^4.2.2",
Expand All @@ -78,13 +67,8 @@
"lodash": "^4.17.21",
"node-emoji": "^1.11.0",
"oauth-1.0a": "^2.2.6",
"open": "^8.4.0",
"puppeteer": "^13.7.0",
"query-string": "^7.1.1",
"raf": "3.4.1",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"regenerator-runtime": "^0.13.9",
"relative-date": "1.1.3",
"sanitize-html": "^2.7.0",
"showdown": "^2.1.0",
Expand All @@ -108,10 +92,5 @@
"type": "git",
"url": "https://github.com/cncf/landscapeapp"
},
"dependenciesMeta": {
"open": {
"unplugged": true
}
},
"packageManager": "yarn@3.2.0"
}
12 changes: 10 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,21 @@ const http = require('http');
const fs = require('fs');
const path = require('path');

const fnFile = (file) => {
const functionsPath = path.join(projectPath, 'dist', process.env.PROJECT_NAME || '', 'functions' );
const destFile = [process.env.PROJECT_NAME, file].filter(_ => _).join('--');
return path.join(functionsPath, destFile);
}

http.createServer(function (request, response) {

if (request.url.indexOf('/api/ids') !== -1) {
console.log('api request starting...', request.url);
const query = request.url.split('?')[1] || '';

if (!process.env.INLINE_API) {
require('child_process').exec(`babel-node src/api/ids.js '${query}'`, {}, function(e, output, err) {
require('child_process').exec(`node ${fnFile("ids.js")} '${query}'`, {}, function(e, output, err) {
console.info(err);
response.writeHead(200, { 'Content-Type': 'application/json' });
response.end(output);
});
Expand All @@ -30,7 +37,7 @@ http.createServer(function (request, response) {
const query = request.url.split('?')[1] || '';

if (!process.env.INLINE_API) {
require('child_process').exec(`babel-node src/api/export.js '${query}'`, {}, function(e, output, err) {
require('child_process').exec(`node ${fnFile("export.js")} '${query}'`, {}, function(e, output, err) {
response.writeHead(200, {
'Content-Type': 'text/css',
'Content-Disposition': 'attachment; filename=interactive-landscape.csv'
Expand All @@ -47,6 +54,7 @@ http.createServer(function (request, response) {
}
return;
}

let filePath = path.join(process.env.PROJECT_PATH, 'dist', request.url.split('?')[0]);
if (fs.existsSync(path.resolve(filePath, 'index.html'))) {
filePath = path.resolve(filePath, 'index.html');
Expand Down
9 changes: 9 additions & 0 deletions specs/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
globals: {
jest: true,
test: true,
it: true,
describe: true,
expect: true
}
};
22 changes: 10 additions & 12 deletions specs/main.spec.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import 'regenerator-runtime/runtime';
import puppeteer from "puppeteer";
import 'expect-puppeteer';
import { paramCase } from 'change-case';
import { settings } from '../tools/settings';
import { projects } from '../tools/loadData';
import { landscapeSettingsList } from "../src/utils/landscapeSettings";
import { appUrl, pathPrefix } from '../tools/distSettings'

const devicesMap = puppeteer.devices;
const puppeteer = require("puppeteer");
require('expect-puppeteer');
const { paramCase } = require('change-case');
const { settings } = require('../tools/settings');
const { projects } = require('../tools/loadData');
const { landscapeSettingsList } = require("../src/utils/landscapeSettings");
const { appUrl, pathPrefix } = require('../tools/distSettings');

const width = 1920;
const height = 1080;

Expand Down Expand Up @@ -40,7 +38,7 @@ async function makePage(initialUrl) {
console.info('retrying...', ex);
browser.close();
} catch(ex2) {

console.info('failed to close browser', ex2);
}
return await makePage(initialUrl);
}
Expand All @@ -65,7 +63,7 @@ describe("Embed test", () => {
page = await makePage(appUrl + '/embed');
frame = await page.frames()[1];
await frame.waitForSelector('.cards-section .mosaic');
await frame.waitForXPath(`//h1[contains(text(), 'full interactive landscape')]`);
await waitForSelector(frame, '#embedded-footer');
});

test('Do not see a content from a main mode', async function() {
Expand Down
3 changes: 1 addition & 2 deletions specs/tools/actualTwitter.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'regenerator-runtime/runtime';
import actualTwitter from '../../tools/actualTwitter';
const { actualTwitter } = require('../../tools/actualTwitter');

describe('Twitter URL', () => {
describe('when crunchbase data not set', () => {
Expand Down
26 changes: 11 additions & 15 deletions src/api/export.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
import path from 'path';
import fs from 'fs';
const { flattenItems } = require('../utils/itemsCalculator');
const { getGroupedItems, expandSecondPathItems } = require('../utils/itemsCalculator');
const { parseParams } = require('../utils/routing');
const Parser = require('json2csv/lib/JSON2CSVParser');
const { readJsonFromDist } = require('../utils/readJson');

import allItems from 'dist/data/items-export';
import projects from 'dist/data/items';
import settings from 'dist/settings'
const allItems = readJsonFromDist('data/items-export');
const projects = readJsonFromDist('data/items');

import { flattenItems, expandSecondPathItems } from '../utils/itemsCalculator';
import getGroupedItems from '../utils/itemsCalculator';
import getSummary, { getSummaryText } from '../utils/summaryCalculator';
import { parseParams } from '../utils/routing';
import Parser from 'json2csv/lib/JSON2CSVParser';

export const processRequest = query => {
const processRequest = module.exports.processRequest = query => {
const params = parseParams(query);
const p = new URLSearchParams(query);
params.format = p.get('format');

let items = projects;
if (params.grouping === 'landscape' || params.format !== 'card') {
items = expandSecondPathItems(items);
};
}

// extract alias - if grouping = category
// extract alias - if params != card-mode (big_picture - always show)
Expand All @@ -28,7 +24,7 @@ export const processRequest = query => {
const selectedItems = flattenItems(getGroupedItems({data: items, ...params}))
.reduce((acc, item) => ({ ...acc, [item.id]: true }), {})

const fields = allItems[0].map(([label, _]) => label !== 'id' && label).filter(_ => _);
const fields = allItems[0].map(([label]) => label !== 'id' && label).filter(_ => _);
const itemsForExport = allItems
.map(item => item.reduce((acc, [label, value]) => ({ ...acc, [label]: value }), {}))
.filter(item => selectedItems[item.id]);
Expand All @@ -39,7 +35,7 @@ export const processRequest = query => {
}

// Netlify function
export async function handler(event, context) {
module.exports.handler = async function(event) {
const body = processRequest(event.queryStringParameters)
const headers = {
'Content-Type': 'text/css',
Expand Down
Loading

0 comments on commit 84749ce

Please sign in to comment.