From e62f93d5e6de12e1553a0c8b275aa8aa07d73c18 Mon Sep 17 00:00:00 2001 From: sneak Date: Fri, 6 Mar 2020 13:32:58 -0800 Subject: [PATCH] need to push to test in ci --- Makefile | 8 ++- README.md | 73 ++++--------------- bin/webstatus-manifest-generator.js | 104 ++++++++++++++++++++++++++++ package.json | 25 +++++-- yarn.lock | 22 ++++++ 5 files changed, 167 insertions(+), 65 deletions(-) create mode 100755 bin/webstatus-manifest-generator.js diff --git a/Makefile b/Makefile index 0c0d7a3..c6ca627 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,9 @@ -build: +build: node_modules yarn build + +node_modules: + yarn install + +clean: + rm -rf build node_modules diff --git a/README.md b/README.md index 9c40dcd..0463517 100644 --- a/README.md +++ b/README.md @@ -1,68 +1,23 @@ -This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). +# webstatus -## Available Scripts +* this is a clientside js web application to consume a directory of static + images on a server and display them in a rotation. -In the project directory, you can run: +# homepage -### `yarn start` +* https://git.eeqj.de/sneak/webstatus -Runs the app in the development mode.
-Open [http://localhost:3000](http://localhost:3000) to view it in the browser. +# todo -The page will reload if you make edits.
-You will also see any lint errors in the console. +* nice transitions +* detect how many px '100%' actually is and don't rescale tiny images beyond + some reasonable measure, so small images can be displayed properly +* allow for text rendering inside the manifest maybe -### `yarn test` +# license -Launches the test runner in the interactive watch mode.
-See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. +WTFPL -### `yarn build` +# author -Builds the app for production to the `build` folder.
-It correctly bundles React in production mode and optimizes the build for the best performance. - -The build is minified and the filenames include the hashes.
-Your app is ready to be deployed! - -See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. - -### `yarn eject` - -**Note: this is a one-way operation. Once you `eject`, you can’t go back!** - -If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. - -Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. - -You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. - -## Learn More - -You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). - -To learn React, check out the [React documentation](https://reactjs.org/). - -### Code Splitting - -This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting - -### Analyzing the Bundle Size - -This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size - -### Making a Progressive Web App - -This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app - -### Advanced Configuration - -This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration - -### Deployment - -This section has moved here: https://facebook.github.io/create-react-app/docs/deployment - -### `yarn build` fails to minify - -This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify +sneak <[sneak@sneak.berlin](mailto:sneak@sneak.berlin)> diff --git a/bin/webstatus-manifest-generator.js b/bin/webstatus-manifest-generator.js new file mode 100755 index 0000000..d338738 --- /dev/null +++ b/bin/webstatus-manifest-generator.js @@ -0,0 +1,104 @@ +#!/usr/bin/env node + +'use strict'; + +const figlet = require('figlet'); +const chalk = require('chalk'); +const fs = require('fs'); + +function recFindByExt(base, ext, files, result) { + files = files || fs.readdirSync(base) + result = result || [] + + files.forEach( + function (file) { + var newbase = path.join(base,file) + if ( fs.statSync(newbase).isDirectory() ) { + result = recFindByExt(newbase,ext,fs.readdirSync(newbase),result) + } else { + if ( file.substr(-1*(ext.length+1)) == '.' + ext ) { + result.push(newbase) + } + } + } + ) + return result +} + +function pprint(obj) { + console.log("%o", obj) +} + +function outputManifest (path, fileList) { + if(!fileList) { + l = [] + } + const output = { + version: 1, + '$id': 'berlin.sneak.ns.webstatus.manifest-v1', + manifest: fileList + } + fs.writeFileSync(path + ".tmp", JSON.stringify(output)) + fs.renameSync(path + ".tmp", path) +} + +function main() { + const commander = require('commander'); + const program = new commander.Command(); + program.version('0.0.1', '-v --version', 'output current version'); + program + .option('-s --source ', 'directory to scan/write', '.') + .option('-v --verbose', 'verbose output', false) + .option('-q --quiet', 'no output', false) + + program.parse(process.argv); + + const print = (x) => { + if(program.quiet) { + return + } + console.log(x) + } + + const log = {} + + log.info = (x) => { + print(chalk.blue(x)) + } + + log.die = (x) => { + print(chalk.bold.red('error: ' + x)) + print(chalk.bold.red('exiting.')) + process.exit(-1) + } + + log.huge = (x) => { + var f = figlet.textSync(x, { + font: 'Red Phoenix', + horizontalLayout: 'default', + verticalLayout: 'default' + }) + print(chalk.red(f)) + } + + log.huge('webstatus') + //const dir = program.source + //pprint(program) + if(!fs.lstatSync(program.source).isDirectory()) { + log.die(`${program.source} is not a directory`) + } else { + log.info(`scanning ${program.source} for images...`) + } + + var fileList = [] + var manifestFilename = program.source + '/webstatus.manifest.json' + + //FIXME scan for files + // + log.info(`writing ${fileList.length} entries to manifest ${manifestFilename}`) + outputManifest(manifestFilename, fileList) + + log.die("unimplemented") +} + +main(); diff --git a/package.json b/package.json index 3ac1cb9..fdf1edb 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,19 @@ { - "name": "webstatus", - "version": "0.1.0", - "private": true, + "name": "@sneak.berlin/webstatus", + "version": "1.0.0", + "description": "webstatus app for displaying a directory of images", + "main": "index.js", + "bin": { + "webstatus-manifest-generator": "./bin/webstatus-manifest-generator.js" + }, "dependencies": { "@testing-library/jest-dom": "^4.2.4", "@testing-library/react": "^9.3.2", "@testing-library/user-event": "^7.1.2", + "chalk": "^3.0.0", + "figlet": "^1.3.0", + "find": "^0.3.0", + "prettier": "^1.19.1", "react": "^16.13.0", "react-dom": "^16.13.0", "react-scripts": "3.4.0" @@ -14,7 +22,8 @@ "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", - "eject": "react-scripts eject" + "eject": "react-scripts eject", + "fmt": "prettier -- --write bin/**/*.js src/**/*.js package.json" }, "eslintConfig": { "extends": "react-app" @@ -30,5 +39,11 @@ "last 1 firefox version", "last 1 safari version" ] - } + }, + "repository": { + "type": "git", + "url": "https://git.eeqj.de/sneak/webstatus.git" + }, + "author": "sneak ", + "license": "WTFPL" } diff --git a/yarn.lock b/yarn.lock index cbf735c..41feac0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4226,6 +4226,11 @@ figgy-pudding@^3.5.1: resolved "https://registry.yarnpkg.com/figgy-pudding/-/figgy-pudding-3.5.1.tgz#862470112901c727a0e495a80744bd5baa1d6790" integrity sha512-vNKxJHTEKNThjfrdJwHc7brvM6eVevuO5nTj6ez8ZQ1qbXTvGthucRF7S4vf2cr71QVnT70V34v0S1DyQsti0w== +figlet@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/figlet/-/figlet-1.3.0.tgz#c49e3d92907ba13bebadc7124f76ba71f1f32ef0" + integrity sha512-f7A8aOJAfyehLJ7lQ6rEA8WJw7kOk3lfWRi5piSjkzbK5YkI5sqO8eiLHz1ehO+DM0QYB85i8VfA6XIGUbU1dg== + figures@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/figures/-/figures-3.1.0.tgz#4b198dd07d8d71530642864af2d45dd9e459c4ec" @@ -4345,6 +4350,13 @@ find-up@^3.0.0: dependencies: locate-path "^3.0.0" +find@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/find/-/find-0.3.0.tgz#4082e8fc8d8320f1a382b5e4f521b9bc50775cb8" + integrity sha512-iSd+O4OEYV/I36Zl8MdYJO0xD82wH528SaCieTVHhclgiYNe9y+yPKSwK+A7/WsmHL1EZ+pYUJBXWTL5qofksw== + dependencies: + traverse-chain "~0.1.0" + flat-cache@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-2.0.1.tgz#5d296d6f04bda44a4630a301413bdbc2ec085ec0" @@ -8055,6 +8067,11 @@ prepend-http@^1.0.0: resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc" integrity sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw= +prettier@^1.19.1: + version "1.19.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb" + integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew== + pretty-bytes@^5.1.0: version "5.3.0" resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-5.3.0.tgz#f2849e27db79fb4d6cfe24764fc4134f165989f2" @@ -9784,6 +9801,11 @@ tr46@^1.0.1: dependencies: punycode "^2.1.0" +traverse-chain@~0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/traverse-chain/-/traverse-chain-0.1.0.tgz#61dbc2d53b69ff6091a12a168fd7d433107e40f1" + integrity sha1-YdvC1Ttp/2CRoSoWj9fUMxB+QPE= + ts-pnp@1.1.5, ts-pnp@^1.1.2: version "1.1.5" resolved "https://registry.yarnpkg.com/ts-pnp/-/ts-pnp-1.1.5.tgz#840e0739c89fce5f3abd9037bb091dbff16d9dec"