From d8bfd39c8980858e1f0691d818441f48a2bcf9be Mon Sep 17 00:00:00 2001 From: Thomas JUND Date: Mon, 28 Sep 2020 17:24:08 +0200 Subject: [PATCH] import publik theming tools --- new_theme.sh | 57 +++++++++ npm_serve.js | 18 +++ package.json | 34 ++++++ postcss-explore/.editorconfig | 15 +++ postcss-explore/.gitignore | 11 ++ postcss-explore/.rollup.js | 16 +++ postcss-explore/.tape.js | 5 + postcss-explore/.travis.yml | 9 ++ postcss-explore/CHANGELOG.md | 5 + postcss-explore/CONTRIBUTING.md | 65 ++++++++++ postcss-explore/INSTALL.md | 170 ++++++++++++++++++++++++++ postcss-explore/LICENSE.md | 108 ++++++++++++++++ postcss-explore/README.md | 61 +++++++++ postcss-explore/package.json | 63 ++++++++++ postcss-explore/src/index.js | 28 +++++ postcss-explore/test/basic.css | 0 postcss-explore/test/basic.expect.css | 0 postcss.config.js | 8 ++ update_publik.sh | 5 + 19 files changed, 678 insertions(+) create mode 100755 new_theme.sh create mode 100644 npm_serve.js create mode 100644 package.json create mode 100644 postcss-explore/.editorconfig create mode 100644 postcss-explore/.gitignore create mode 100644 postcss-explore/.rollup.js create mode 100644 postcss-explore/.tape.js create mode 100644 postcss-explore/.travis.yml create mode 100644 postcss-explore/CHANGELOG.md create mode 100644 postcss-explore/CONTRIBUTING.md create mode 100644 postcss-explore/INSTALL.md create mode 100644 postcss-explore/LICENSE.md create mode 100644 postcss-explore/README.md create mode 100644 postcss-explore/package.json create mode 100644 postcss-explore/src/index.js create mode 100644 postcss-explore/test/basic.css create mode 100644 postcss-explore/test/basic.expect.css create mode 100644 postcss.config.js create mode 100755 update_publik.sh diff --git a/new_theme.sh b/new_theme.sh new file mode 100755 index 0000000..408d48d --- /dev/null +++ b/new_theme.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +# folder Name +read -p 'folder name : ' folderName +# Theme Label +read -p 'Theme label : ' themeLabel +# Theme Color +read -p 'Theme Color (hexa) : ' themeColor +# Active PWA +read -p 'Active PWA (0/1) : ' pwa + +cd ~/src/publik-base-theme/ + +# create folder +themefolderPath=static/$folderName +mkdir $themefolderPath + +# store config PWA +if [ $pwa == 1 ] +then + configPWA='"pwa_display": "standalone",' +fi + +# create config.json file +cat >${themefolderPath}/config.json <${themefolderPath}/style.scss < /tmp/explorecss.txt", + "stop:memcache": "sudo systemctl stop memcached", + "build:css": "cd $npm_package_config_themefolder && make static/$npm_package_config_theme/style.css", + "build:themes": "cd $npm_package_config_themefolder && make themes.json", + "watch:scss": "cd $npm_package_config_themefolder && chokidar 'static/**/*.scss' -c 'npm run build:css'", + "watch:config": "cd $npm_package_config_themefolder && chokidar 'static/**/config.json' -c 'npm run build:themes'", + "serve": "node npm_serve.js", + "dev": "run-p watch:* & npm run serve" + }, + "devDependencies": { + "browser-sync": "^2.26.7", + "chokidar-cli": "^2.0.0", + "eslint": "^7.7.0", + "npm-run-all": "^4.1.5", + "postcss-cli": "^7.1.2" + } +} diff --git a/postcss-explore/.editorconfig b/postcss-explore/.editorconfig new file mode 100644 index 0000000..e06d798 --- /dev/null +++ b/postcss-explore/.editorconfig @@ -0,0 +1,15 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_style = tab +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false + +[*.{json,md,yml}] +indent_size = 2 +indent_style = space diff --git a/postcss-explore/.gitignore b/postcss-explore/.gitignore new file mode 100644 index 0000000..688f9cb --- /dev/null +++ b/postcss-explore/.gitignore @@ -0,0 +1,11 @@ +.* +!.editorconfig +!.gitignore +!.rollup.js +!.tape.js +!.travis.yml +*.log* +*.result.css +/index.* +node_modules +package-lock.json diff --git a/postcss-explore/.rollup.js b/postcss-explore/.rollup.js new file mode 100644 index 0000000..1a4c229 --- /dev/null +++ b/postcss-explore/.rollup.js @@ -0,0 +1,16 @@ +import babel from 'rollup-plugin-babel'; + +export default { + input: 'src/index.js', + output: [ + { file: 'index.js', format: 'cjs', sourcemap: true, strict: false }, + { file: 'index.mjs', format: 'esm', sourcemap: true, strict: false } + ], + plugins: [ + babel({ + presets: [ + ['@babel/env', { modules: false, targets: { node: 8 } }] + ] + }) + ] +}; diff --git a/postcss-explore/.tape.js b/postcss-explore/.tape.js new file mode 100644 index 0000000..adcbad9 --- /dev/null +++ b/postcss-explore/.tape.js @@ -0,0 +1,5 @@ +module.exports = { + 'basic': { + message: 'supports basic usage' + } +}; diff --git a/postcss-explore/.travis.yml b/postcss-explore/.travis.yml new file mode 100644 index 0000000..6ebed1d --- /dev/null +++ b/postcss-explore/.travis.yml @@ -0,0 +1,9 @@ +# https://docs.travis-ci.com/user/travis-lint + +language: node_js + +node_js: + - 8 + +install: + - npm install --ignore-scripts diff --git a/postcss-explore/CHANGELOG.md b/postcss-explore/CHANGELOG.md new file mode 100644 index 0000000..64494a1 --- /dev/null +++ b/postcss-explore/CHANGELOG.md @@ -0,0 +1,5 @@ +# Changes to PostCSS postcss-explore + +### 1.0.0 (September 18, 2020) + +- Initial version diff --git a/postcss-explore/CONTRIBUTING.md b/postcss-explore/CONTRIBUTING.md new file mode 100644 index 0000000..2a577c3 --- /dev/null +++ b/postcss-explore/CONTRIBUTING.md @@ -0,0 +1,65 @@ +# Contributing to PostCSS postcss-explore + +You want to help? You rock! Now, take a moment to be sure your contributions +make sense to everyone else. + +## Reporting Issues + +Found a problem? Want a new feature? + +- See if your issue or idea has [already been reported]. +- Provide a [reduced test case] or a [live example]. + +Remember, a bug is a _demonstrable problem_ caused by _our_ code. + +## Submitting Pull Requests + +Pull requests are the greatest contributions, so be sure they are focused in +scope and avoid unrelated commits. + +1. To begin; [fork this project], clone your fork, and add our upstream. + ```bash + # Clone your fork of the repo into the current directory + git clone git@github.com:YOUR_USER/postcss-postcss-explore.git + + # Navigate to the newly cloned directory + cd postcss-postcss-explore + + # Assign the original repo to a remote called "upstream" + git remote add upstream git@github.com:csstools/postcss-postcss-explore.git + + # Install the tools necessary for testing + npm install + ``` + +2. Create a branch for your feature or fix: + ```bash + # Move into a new branch for your feature + git checkout -b feature/thing + ``` + ```bash + # Move into a new branch for your fix + git checkout -b fix/something + ``` + +3. If your code follows our practices, then push your feature branch: + ```bash + # Test current code + npm test + ``` + ```bash + # Push the branch for your new feature + git push origin feature/thing + ``` + ```bash + # Or, push the branch for your update + git push origin update/something + ``` + +That’s it! Now [open a pull request] with a clear title and description. + +[already been reported]: issues +[fork this project]: fork +[live example]: https://codepen.io/pen +[open a pull request]: https://help.github.com/articles/using-pull-requests/ +[reduced test case]: https://css-tricks.com/reduced-test-cases/ diff --git a/postcss-explore/INSTALL.md b/postcss-explore/INSTALL.md new file mode 100644 index 0000000..7ed18b0 --- /dev/null +++ b/postcss-explore/INSTALL.md @@ -0,0 +1,170 @@ +# Installing PostCSS postcss-explore + +[PostCSS postcss-explore] runs in all Node environments, with special instructions for: + +| [Node](#node) | [PostCSS CLI](#postcss-cli) | [Webpack](#webpack) | [Create React App](#create-react-app) | [Gulp](#gulp) | [Grunt](#grunt) | +| --- | --- | --- | --- | --- | --- | + +## Node + +Add [PostCSS postcss-explore] to your project: + +```bash +npm install postcss-postcss-explore --save-dev +``` + +Use **PostCSS postcss-explore** to process your CSS: + +```js +const postcssPostcssExplore = require('postcss-postcss-explore'); + +postcssPostcssExplore.process(YOUR_CSS /*, processOptions, pluginOptions */); +``` + +Or use it as a [PostCSS] plugin: + +```js +const postcss = require('postcss'); +const postcssPostcssExplore = require('postcss-postcss-explore'); + +postcss([ + postcssPostcssExplore(/* pluginOptions */) +]).process(YOUR_CSS /*, processOptions */); +``` + +## PostCSS CLI + +Add [PostCSS CLI] to your project: + +```bash +npm install postcss-cli --save-dev +``` + +Use **PostCSS postcss-explore** in your `postcss.config.js` configuration file: + +```js +const postcssPostcssExplore = require('postcss-postcss-explore'); + +module.exports = { + plugins: [ + postcssPostcssExplore(/* pluginOptions */) + ] +} +``` + +## Webpack + +Add [PostCSS Loader] to your project: + +```bash +npm install postcss-loader --save-dev +``` + +Use **PostCSS postcss-explore** in your Webpack configuration: + +```js +const postcssPostcssExplore = require('postcss-postcss-explore'); + +module.exports = { + module: { + rules: [ + { + test: /\.css$/, + use: [ + 'style-loader', + { loader: 'css-loader', options: { importLoaders: 1 } }, + { loader: 'postcss-loader', options: { + ident: 'postcss', + plugins: () => [ + postcssPostcssExplore(/* pluginOptions */) + ] + } } + ] + } + ] + } +} +``` + +## Create React App + +Add [React App Rewired] and [React App Rewire PostCSS] to your project: + +```bash +npm install react-app-rewired react-app-rewire-postcss --save-dev +``` + +Use **React App Rewire PostCSS** and **PostCSS postcss-explore** in your +`config-overrides.js` file: + +```js +const reactAppRewirePostcss = require('react-app-rewire-postcss'); +const postcssPostcssExplore = require('postcss-postcss-explore'); + +module.exports = config => reactAppRewirePostcss(config, { + plugins: () => [ + postcssPostcssExplore(/* pluginOptions */) + ] +}); +``` + +## Gulp + +Add [Gulp PostCSS] to your project: + +```bash +npm install gulp-postcss --save-dev +``` + +Use **PostCSS postcss-explore** in your Gulpfile: + +```js +const postcss = require('gulp-postcss'); +const postcssPostcssExplore = require('postcss-postcss-explore'); + +gulp.task('css', () => gulp.src('./src/*.css').pipe( + postcss([ + postcssPostcssExplore(/* pluginOptions */) + ]) +).pipe( + gulp.dest('.') +)); +``` + +## Grunt + +Add [Grunt PostCSS] to your project: + +```bash +npm install grunt-postcss --save-dev +``` + +Use **PostCSS postcss-explore** in your Gruntfile: + +```js +const postcssPostcssExplore = require('postcss-postcss-explore'); + +grunt.loadNpmTasks('grunt-postcss'); + +grunt.initConfig({ + postcss: { + options: { + use: [ + postcssPostcssExplore(/* pluginOptions */) + ] + }, + dist: { + src: '*.css' + } + } +}); +``` + +[Gulp PostCSS]: https://github.com/postcss/gulp-postcss +[Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss +[PostCSS]: https://github.com/postcss/postcss +[PostCSS CLI]: https://github.com/postcss/postcss-cli +[PostCSS Loader]: https://github.com/postcss/postcss-loader +[PostCSS postcss-explore]: https://github.com/sacripant/postcss-postcss-explore +[React App Rewire PostCSS]: https://github.com/csstools/react-app-rewire-postcss +[React App Rewired]: https://github.com/timarney/react-app-rewired diff --git a/postcss-explore/LICENSE.md b/postcss-explore/LICENSE.md new file mode 100644 index 0000000..0bc1fa7 --- /dev/null +++ b/postcss-explore/LICENSE.md @@ -0,0 +1,108 @@ +# CC0 1.0 Universal + +## Statement of Purpose + +The laws of most jurisdictions throughout the world automatically confer +exclusive Copyright and Related Rights (defined below) upon the creator and +subsequent owner(s) (each and all, an “owner”) of an original work of +authorship and/or a database (each, a “Work”). + +Certain owners wish to permanently relinquish those rights to a Work for the +purpose of contributing to a commons of creative, cultural and scientific works +(“Commons”) that the public can reliably and without fear of later claims of +infringement build upon, modify, incorporate in other works, reuse and +redistribute as freely as possible in any form whatsoever and for any purposes, +including without limitation commercial purposes. These owners may contribute +to the Commons to promote the ideal of a free culture and the further +production of creative, cultural and scientific works, or to gain reputation or +greater distribution for their Work in part through the use and efforts of +others. + +For these and/or other purposes and motivations, and without any expectation of +additional consideration or compensation, the person associating CC0 with a +Work (the “Affirmer”), to the extent that he or she is an owner of Copyright +and Related Rights in the Work, voluntarily elects to apply CC0 to the Work and +publicly distribute the Work under its terms, with knowledge of his or her +Copyright and Related Rights in the Work and the meaning and intended legal +effect of CC0 on those rights. + +1. Copyright and Related Rights. A Work made available under CC0 may be + protected by copyright and related or neighboring rights (“Copyright and + Related Rights”). Copyright and Related Rights include, but are not limited + to, the following: + 1. the right to reproduce, adapt, distribute, perform, display, communicate, + and translate a Work; + 2. moral rights retained by the original author(s) and/or performer(s); + 3. publicity and privacy rights pertaining to a person’s image or likeness + depicted in a Work; + 4. rights protecting against unfair competition in regards to a Work, + subject to the limitations in paragraph 4(i), below; + 5. rights protecting the extraction, dissemination, use and reuse of data in + a Work; + 6. database rights (such as those arising under Directive 96/9/EC of the + European Parliament and of the Council of 11 March 1996 on the legal + protection of databases, and under any national implementation thereof, + including any amended or successor version of such directive); and + 7. other similar, equivalent or corresponding rights throughout the world + based on applicable law or treaty, and any national implementations + thereof. + +2. Waiver. To the greatest extent permitted by, but not in contravention of, + applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and + unconditionally waives, abandons, and surrenders all of Affirmer’s Copyright + and Related Rights and associated claims and causes of action, whether now + known or unknown (including existing as well as future claims and causes of + action), in the Work (i) in all territories worldwide, (ii) for the maximum + duration provided by applicable law or treaty (including future time + extensions), (iii) in any current or future medium and for any number of + copies, and (iv) for any purpose whatsoever, including without limitation + commercial, advertising or promotional purposes (the “Waiver”). Affirmer + makes the Waiver for the benefit of each member of the public at large and + to the detriment of Affirmer’s heirs and successors, fully intending that + such Waiver shall not be subject to revocation, rescission, cancellation, + termination, or any other legal or equitable action to disrupt the quiet + enjoyment of the Work by the public as contemplated by Affirmer’s express + Statement of Purpose. + +3. Public License Fallback. Should any part of the Waiver for any reason be + judged legally invalid or ineffective under applicable law, then the Waiver + shall be preserved to the maximum extent permitted taking into account + Affirmer’s express Statement of Purpose. In addition, to the extent the + Waiver is so judged Affirmer hereby grants to each affected person a + royalty-free, non transferable, non sublicensable, non exclusive, + irrevocable and unconditional license to exercise Affirmer’s Copyright and + Related Rights in the Work (i) in all territories worldwide, (ii) for the + maximum duration provided by applicable law or treaty (including future time + extensions), (iii) in any current or future medium and for any number of + copies, and (iv) for any purpose whatsoever, including without limitation + commercial, advertising or promotional purposes (the “License”). The License + shall be deemed effective as of the date CC0 was applied by Affirmer to the + Work. Should any part of the License for any reason be judged legally + invalid or ineffective under applicable law, such partial invalidity or + ineffectiveness shall not invalidate the remainder of the License, and in + such case Affirmer hereby affirms that he or she will not (i) exercise any + of his or her remaining Copyright and Related Rights in the Work or (ii) + assert any associated claims and causes of action with respect to the Work, + in either case contrary to Affirmer’s express Statement of Purpose. + +4. Limitations and Disclaimers. + 1. No trademark or patent rights held by Affirmer are waived, abandoned, + surrendered, licensed or otherwise affected by this document. + 2. Affirmer offers the Work as-is and makes no representations or warranties + of any kind concerning the Work, express, implied, statutory or + otherwise, including without limitation warranties of title, + merchantability, fitness for a particular purpose, non infringement, or + the absence of latent or other defects, accuracy, or the present or + absence of errors, whether or not discoverable, all to the greatest + extent permissible under applicable law. + 3. Affirmer disclaims responsibility for clearing rights of other persons + that may apply to the Work or any use thereof, including without + limitation any person’s Copyright and Related Rights in the Work. + Further, Affirmer disclaims responsibility for obtaining any necessary + consents, permissions or other rights required for any use of the Work. + 4. Affirmer understands and acknowledges that Creative Commons is not a + party to this document and has no duty or obligation with respect to this + CC0 or use of the Work. + +For more information, please see +http://creativecommons.org/publicdomain/zero/1.0/. diff --git a/postcss-explore/README.md b/postcss-explore/README.md new file mode 100644 index 0000000..18598f1 --- /dev/null +++ b/postcss-explore/README.md @@ -0,0 +1,61 @@ +# PostCSS postcss-explore [PostCSS][postcss] + +[![NPM Version][npm-img]][npm-url] +[![Build Status][cli-img]][cli-url] +[![Support Chat][git-img]][git-url] + +[PostCSS postcss-explore] lets you ... in CSS. + +```pcss +.example { ... } + +/* becomes */ + +.example { ... } +``` + +## Usage + +Add [PostCSS postcss-explore] to your project: + +```bash +npm install postcss-postcss-explore --save-dev +``` + +Use **PostCSS postcss-explore** to process your CSS: + +```js +const postcssPostcssExplore = require('postcss-postcss-explore'); + +postcssPostcssExplore.process(YOUR_CSS /*, processOptions, pluginOptions */); +``` + +Or use it as a [PostCSS] plugin: + +```js +const postcss = require('postcss'); +const postcssPostcssExplore = require('postcss-postcss-explore'); + +postcss([ + postcssPostcssExplore(/* pluginOptions */) +]).process(YOUR_CSS /*, processOptions */); +``` + +**PostCSS postcss-explore** runs in all Node environments, with special instructions for: + +| [Node](INSTALL.md#node) | [PostCSS CLI](INSTALL.md#postcss-cli) | [Webpack](INSTALL.md#webpack) | [Create React App](INSTALL.md#create-react-app) | [Gulp](INSTALL.md#gulp) | [Grunt](INSTALL.md#grunt) | +| --- | --- | --- | --- | --- | --- | + +## Options + +... + +[cli-img]: https://img.shields.io/travis/sacripant/postcss-postcss-explore/master.svg +[cli-url]: https://travis-ci.org/sacripant/postcss-postcss-explore +[git-img]: https://img.shields.io/badge/support-chat-blue.svg +[git-url]: https://gitter.im/postcss/postcss +[npm-img]: https://img.shields.io/npm/v/postcss-postcss-explore.svg +[npm-url]: https://www.npmjs.com/package/postcss-postcss-explore + +[PostCSS]: https://github.com/postcss/postcss +[PostCSS postcss-explore]: https://github.com/sacripant/postcss-postcss-explore diff --git a/postcss-explore/package.json b/postcss-explore/package.json new file mode 100644 index 0000000..02c22fe --- /dev/null +++ b/postcss-explore/package.json @@ -0,0 +1,63 @@ +{ + "name": "postcss-postcss-explore", + "version": "1.0.0", + "description": "... in CSS", + "author": "Jund ", + "license": "CC0-1.0", + "repository": "sacripant/postcss-postcss-explore", + "homepage": "https://github.com/sacripant/postcss-postcss-explore#readme", + "bugs": "https://github.com/sacripant/postcss-postcss-explore/issues", + "main": "index.js", + "module": "index.mjs", + "files": [ + "index.js", + "index.js.map", + "index.mjs", + "index.mjs.map" + ], + "scripts": { + "build": "rollup --config .rollup.js --silent", + "prepublishOnly": "npm test", + "pretest:tape": "npm run build", + "test": "npm run test:js && npm run test:tape", + "test:js": "eslint src/{*,**/*}.js --cache --ignore-path .gitignore --quiet", + "test:tape": "postcss-tape" + }, + "engines": { + "node": ">=8.0.0" + }, + "dependencies": { + "postcss": "^7.0.21" + }, + "devDependencies": { + "@babel/core": "^7.7.2", + "@babel/preset-env": "^7.7.1", + "babel-eslint": "^10.0.3", + "eslint": "^6.6.0", + "postcss-tape": "^5.0.2", + "pre-commit": "^1.2.2", + "rollup": "^1.26.3", + "rollup-plugin-babel": "^4.3.3" + }, + "eslintConfig": { + "env": { + "browser": true, + "es6": true, + "node": true + }, + "extends": "eslint:recommended", + "parser": "babel-eslint", + "parserOptions": { + "ecmaVersion": 2018, + "impliedStrict": true, + "sourceType": "module" + }, + "root": true + }, + "keywords": [ + "postcss", + "css", + "postcss-plugin", + "" + ] +} diff --git a/postcss-explore/src/index.js b/postcss-explore/src/index.js new file mode 100644 index 0000000..e21089c --- /dev/null +++ b/postcss-explore/src/index.js @@ -0,0 +1,28 @@ +import postcss from 'postcss'; + +export default postcss.plugin('postcss-postcss-explore', opts => { + + return (root) => { + // console.log({ root, result }); // eslint-disable-line no-console + let startLine = 0; + root.walkComments( (comment) => { + if (comment.text == "End of core styles") + startLine = comment.source.start.line; + }); + + root.walkRules( opts.selector, (rule, index) => { + const ruleLine = rule.source.start.line; + if (ruleLine <= startLine) return; + + rule.walkDecls( opts.propertie, decl => { + console.group(rule.source.input.from); + console.group(rule.selector); + console.log(decl.prop, decl.value); + console.log(decl.source.start); + console.groupEnd(); + console.groupEnd(); + console.log(""); + }); + }); + }; +}); \ No newline at end of file diff --git a/postcss-explore/test/basic.css b/postcss-explore/test/basic.css new file mode 100644 index 0000000..e69de29 diff --git a/postcss-explore/test/basic.expect.css b/postcss-explore/test/basic.expect.css new file mode 100644 index 0000000..e69de29 diff --git a/postcss.config.js b/postcss.config.js new file mode 100644 index 0000000..a68cc8e --- /dev/null +++ b/postcss.config.js @@ -0,0 +1,8 @@ +module.exports = { + plugins: [ + require('postcss-explore')({ + selector: /\.cell$/, + propertie: /^border/ + }) + ], +} \ No newline at end of file diff --git a/update_publik.sh b/update_publik.sh new file mode 100755 index 0000000..4afeb24 --- /dev/null +++ b/update_publik.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +cd ~/src/publik-devinst +git pull +ansible-playbook -K -i thomas-inventory.yml install.yml \ No newline at end of file