]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
workflow: include commit link in template explorer
authorEvan You <yyx990803@gmail.com>
Sat, 5 Oct 2019 02:40:54 +0000 (22:40 -0400)
committerEvan You <yyx990803@gmail.com>
Sat, 5 Oct 2019 02:40:54 +0000 (22:40 -0400)
packages/global.d.ts
packages/template-explorer/src/options.ts
packages/template-explorer/style.css
rollup.config.js
scripts/build.js
scripts/dev.js

index 0d81152785759c1863274b90044e2d9188b65ec5..6741396ace9a880836404607e79105ca092a4d9e 100644 (file)
@@ -2,6 +2,7 @@
 declare var __DEV__: boolean
 declare var __JSDOM__: boolean
 declare var __BROWSER__: boolean
+declare var __COMMIT__: string
 
 // Feature flags
 declare var __FEATURE_OPTIONS__: boolean
index 9d6e49767e58237f9b0f6023dd8d316370f106d7..204811102eff8d6ec4d75d998fdd8469d4e9d074 100644 (file)
@@ -11,6 +11,14 @@ const App = {
   setup() {
     return () => [
       h('h1', `Vue 3 Template Explorer`),
+      h(
+        'a',
+        {
+          href: `https://github.com/vuejs/vue-next/tree/${__COMMIT__}`,
+          target: `_blank`
+        },
+        `@${__COMMIT__}`
+      ),
       h('div', { id: 'options' }, [
         // mode selection
         h('span', { class: 'options-group' }, [
index defada1aadb5e99d050dfac201ab48d5f4adb1d5..fca19d04a450a387faa8f55b6d5457ed4559fe19 100644 (file)
@@ -19,6 +19,7 @@ body {
 h1 {
   font-size: 18px;
   display: inline-block;
+  margin-right: 15px;
 }
 
 #options {
@@ -30,10 +31,15 @@ h1 {
   margin-right: 30px;
 }
 
-#header span, #header label, #header input {
+#header span, #header label, #header input, #header a {
   display: inline-block;
 }
 
+#header a {
+  font-weight: 600;
+  color: rgb(101, 163, 221);
+}
+
 #header .label {
   font-weight: bold;
 }
index 9988a4a64dd9c8783cedc1e7f36662b02fb48945..c94a7f9816ab5f1dec7ced05ddfe94b71994f14b 100644 (file)
@@ -133,6 +133,7 @@ function createConfig(output, plugins = []) {
 
 function createReplacePlugin(isProduction, isBunlderESMBuild, isBrowserBuild) {
   return replace({
+    __COMMIT__: `"${process.env.COMMIT}"`,
     __DEV__: isBunlderESMBuild
       ? // preserve to be handled by bundlers
         `process.env.NODE_ENV !== 'production'`
index 6735673260508d47c9c558b93b6f7b4aeb008f91..f8e7b3050d718a6ee319503756bcc6732e64b844 100644 (file)
@@ -29,6 +29,7 @@ const formats = args.formats || args.f
 const devOnly = args.devOnly || args.d
 const prodOnly = !devOnly && (args.prodOnly || args.p)
 const buildAllMatching = args.all || args.a
+const commit = execa.sync('git', ['rev-parse', 'HEAD']).stdout.slice(0, 7)
 ;(async () => {
   if (!targets.length) {
     await buildAll(allTargets)
@@ -60,11 +61,16 @@ async function build(target) {
     [
       '-c',
       '--environment',
-      `NODE_ENV:${env},` +
-        `TARGET:${target}` +
-        (formats ? `,FORMATS:${formats}` : ``) +
-        (args.types ? `,TYPES:true` : ``) +
-        (prodOnly ? `,PROD_ONLY:true` : ``)
+      [
+        `COMMIT:${commit}`,
+        `NODE_ENV:${env}`,
+        `TARGET:${target}`,
+        formats ? `FORMATS:${formats}` : ``,
+        args.types ? `TYPES:true` : ``,
+        prodOnly ? `PROD_ONLY:true` : ``
+      ]
+        .filter(_ => _)
+        .join(',')
     ],
     { stdio: 'inherit' }
   )
index e7e403785932cec68999bce9b44b3442a6ab2e72..d21c3272e53ea46955e84ca8affdb81c81c5e86f 100644 (file)
@@ -22,10 +22,19 @@ const { targets, fuzzyMatchTarget } = require('./utils')
 const args = require('minimist')(process.argv.slice(2))
 const target = args._.length ? fuzzyMatchTarget(args._)[0] : 'vue'
 const formats = args.formats || args.f
+const commit = execa.sync('git', ['rev-parse', 'HEAD']).stdout.slice(0, 7)
 
 execa(
   'rollup',
-  ['-wc', '--environment', `TARGET:${target},FORMATS:${formats || 'global'}`],
+  [
+    '-wc',
+    '--environment',
+    [
+      `COMMIT:${commit}`,
+      `TARGET:${target}`,
+      `FORMATS:${formats || 'global'}`
+    ].join(',')
+  ],
   {
     stdio: 'inherit'
   }