Bläddra i källkod

feat(try): initial attempt at updating style.css

Sarah Norris 3 år sedan
förälder
incheckning
58a2ec94a9
4 ändrade filer med 17 tillägg och 2 borttagningar
  1. 1 0
      .github/workflows/update-themes.yml
  2. 2 1
      blockbase/package.json
  3. 3 1
      package.json
  4. 11 0
      theme-utils.mjs

+ 1 - 0
.github/workflows/update-themes.yml

@@ -25,3 +25,4 @@ jobs:
       - run: git config --global user.name "github-actions[bot]"
       - run: npm ci
       - run: npm run update-themes
+      #- run: git push

+ 2 - 1
blockbase/package.json

@@ -34,6 +34,7 @@
   ],
   "scripts": {
     "start": "chokidar \"sass/**/*.scss\" -c \"npm run build\" --initial",
-    "build": "node-sass --importer node_modules/node-sass-package-importer/dist/cli.js sass/ponyfill.scss assets/ponyfill.css --output-style expanded --indent-type tab --indent-width 1 --source-map true"
+    "build": "node-sass --importer node_modules/node-sass-package-importer/dist/cli.js sass/ponyfill.scss assets/ponyfill.css --output-style expanded --indent-type tab --indent-width 1 --source-map true",
+    "stylecss-version": "node ../theme-utils.mjs lerna-update-stylecss"
   }
 }

+ 3 - 1
package.json

@@ -26,7 +26,9 @@
 		"deploy:preview": "node ./theme-utils.mjs deploy-preview",
 		"build:zip": "node ./theme-utils.mjs build-com-zip",
 		"commit": "npx cz",
-		"update-themes": "npx lerna version --conventional-commits --no-commit-hooks --yes"
+		"prep-updates": "npx lerna version --conventional-commits --no-commit-hooks --no-push --yes",
+		"update-stylecss": "npx lerna run stylecss-version --since",
+		"update-themes": "npm run prep-updates && npm run prep-css"
 	},
 	"devDependencies": {
 		"@commitlint/cli": "^15.0.0",

+ 11 - 0
theme-utils.mjs

@@ -26,6 +26,7 @@ const isWin = process.platform === 'win32';
 		case "deploy-preview": return deployPreview();
 		case "deploy-theme": return deployThemes([args?.[1]]);
 		case "build-com-zip": return buildComZip([args?.[1]]);
+		case "lerna-update-stylecss": return lernaUpdateStyleCss();
 	}
 	return showHelp();
 })();
@@ -35,6 +36,16 @@ function showHelp(){
 	console.log('Help info can go here');
 }
 
+async function lernaUpdateStyleCss(theme, newVersion) {
+	console.log('Update style.css versions');
+	if (!theme || !newVersion) {
+		return;
+	}
+
+	let styleCss = fs.readFileSync(`${theme}/style.css`, 'utf8');
+	await executeCommand(`perl -pi -e 's/Version: (.*)$/"Version: '${newVersion}'"/ge' ${styleCss}`);
+}
+
 /*
  Determine what changes would be deployed
 */