-
-
Notifications
You must be signed in to change notification settings - Fork 79k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a script to zip the built examples #30130
Conversation
Obviously. This is ran after the docs are generated this the folder is
present
…On Mon, Feb 3, 2020, 21:24 Martijn Cuppens ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In package.json
<#30130 (comment)>:
> "release-sri": "node build/generate-sri.js",
"release-version": "node build/change-version.js",
"release-zip": "cross-env-shell \"rm -rf bootstrap-$npm_package_version-dist && cp -r dist/ bootstrap-$npm_package_version-dist && zip -r9 bootstrap-$npm_package_version-dist.zip bootstrap-$npm_package_version-dist && rm -rf bootstrap-$npm_package_version-dist\"",
+ "release-zip-examples": "cross-env-shell \"rm -rf bootstrap-$npm_package_version-examples && cp -r _gh_pages/docs/$npm_package_version_short/examples/ bootstrap-$npm_package_version-examples && rm bootstrap-$npm_package_version-examples/index.html && zip -r9 bootstrap-$npm_package_version-examples.zip bootstrap-$npm_package_version-examples && rm -rf bootstrap-$npm_package_version-examples\"",
I got an error when I removed the _gh_pages folder and reran the command.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#30130?email_source=notifications&email_token=AACVLNMUYXNMOU7EDT2FWXTRBBVO3A5CNFSM4KPCFOEKYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCUBL3VY#pullrequestreview-352501207>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACVLNPNDMJU65OOVOLENBDRBBVO3ANCNFSM4KPCFOEA>
.
|
How about we mention the examples zip package in getting started? |
12c7ac7
to
ed67acf
Compare
Now that I think about it, I'm not happy with this patch. The asset paths still are I'm not sure how to solve this in an easy way. |
And even if we set up https://gohugo.io/content-management/urls/#relative-urls, it'll still need further processing to keep the directory structure simple. Otherwise try this patch: config.yml | 1 +
package.json | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/config.yml b/config.yml
index 63648ec1a..3ccc68b54 100644
--- a/config.yml
+++ b/config.yml
@@ -10,6 +10,7 @@ markup:
highlight:
noClasses: false
+relativeURLs: true
buildDrafts: true
buildFuture: true
diff --git a/package.json b/package.json
index bc78e8882..4e7b1aeb6 100644
--- a/package.json
+++ b/package.json
@@ -61,7 +61,7 @@
"release-sri": "node build/generate-sri.js",
"release-version": "node build/change-version.js",
"release-zip": "cross-env-shell \"rm -rf bootstrap-$npm_package_version-dist && cp -r dist/ bootstrap-$npm_package_version-dist && zip -r9 bootstrap-$npm_package_version-dist.zip bootstrap-$npm_package_version-dist && rm -rf bootstrap-$npm_package_version-dist\"",
- "release-zip-examples": "cross-env-shell \"rm -rf bootstrap-$npm_package_version-examples && cp -r _gh_pages/docs/$npm_package_version_short/examples/ bootstrap-$npm_package_version-examples && rm bootstrap-$npm_package_version-examples/index.html && zip -r9 bootstrap-$npm_package_version-examples.zip bootstrap-$npm_package_version-examples && rm -rf bootstrap-$npm_package_version-examples\"",
+ "release-zip-examples": "cross-env-shell \"rm -rf bootstrap-$npm_package_version-examples && zip -r9 bootstrap-$npm_package_version-examples.zip _gh_pages/docs/$npm_package_version_short/examples/ _gh_pages/docs/$npm_package_version_short/dist/",
"dist": "npm-run-all --parallel css js",
"test": "npm-run-all lint dist js-test docs-build docs-lint",
"netlify": "npm-run-all dist release-sri docs-production",
|
0a47957
to
7e22269
Compare
So basically this works fine:
If I don't find a solution with |
8e6bf81
to
d648c02
Compare
The bootstrap CSS, JS and favicons are not included in the zip files here |
The CSS and JS is included for sure. The favicons are not included on purpose. |
Indeed, never mind |
It seems we also need to remove the integrity and crossorigin attributes, otherwise I get cross origin errors when I open the html file through my filesystem:
|
For that I'd need some help, so feel free to tweak the script. |
0519791
to
a5864bd
Compare
a5864bd
to
8e2f74c
Compare
@mdo @MartijnCuppens @ffoodd can you guys try this now? Not sure if the regex is perfect, but it seems to work. I also confirmed the dashboard example works since it has 3rd-party scripts. |
build/zip-examples.sh
Outdated
cp -r "_gh_pages/docs/$version_short/examples/" "$folder_name" | ||
cp -r "_gh_pages/docs/$version_short/dist/" "$folder_name" | ||
rm "$folder_name/index.html" | ||
find "$folder_name" -name "*.html" -exec sed -i "s#\"/docs/$version_short/#\"../#g" '{}' \; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tighten this so that it only changes links
and script
tags, not a
tags
It works! Some sidenotes:
|
Already in the PR TODO, but I might not be able to remove them and TBH I don't think it's an issue.
Unrelated to this PR, though. 😛 |
|
||
// remove any previously create folder with the same name | ||
sh.rm('-rf', folderName) | ||
sh.mkdir('-p', folderName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a bit weird to use sh
here, you can use native Node.js methods to do that, it'll work everywhere
build/zip-examples.js
Outdated
const path = require('path') | ||
const sh = require('shelljs') | ||
|
||
const { version, version_short } = require('../package.json') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const { version, version_short: versionShort } = require('../package.json')
to avoid using: /* eslint-disable camelcase */
Sure, feel free to submit a patch ;)
I went with something we already have in our devDependencies and it was
easier for me.
Happy to remove shelljs if you manage to remove it from the other scripts
too.
…On Thu, Apr 2, 2020, 12:39 Johann-S ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In build/zip-examples.js
<#30130 (comment)>:
> +
+const path = require('path')
+const sh = require('shelljs')
+
+const { version, version_short } = require('../package.json')
+
+const folderName = `bootstrap-${version}-examples`
+
+sh.config.fatal = true
+
+// switch to the root dir
+sh.cd(path.join(__dirname, '..'))
+
+// remove any previously create folder with the same name
+sh.rm('-rf', folderName)
+sh.mkdir('-p', folderName)
it's a bit weird to use sh here, you can use native Node.js methods to do
that, it'll work everywhere
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#30130 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACVLNJWJWUVIC3PWSK6SQDRKRMOFANCNFSM4KPCFOEA>
.
|
|
||
/*! | ||
* Script to create the built examples zip archive; | ||
* requires the `zip` command to be present! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we can add a devDeps to avoid this requirement ?
That's a system utility not an npm package.
…On Thu, Apr 2, 2020, 12:45 Johann-S ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In build/zip-examples.js
<#30130 (comment)>:
> @@ -0,0 +1,49 @@
+#!/usr/bin/env node
+
+/*!
+ * Script to create the built examples zip archive;
+ * requires the `zip` command to be present!
maybe we can add a devDeps to avoid this requirement ?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#30130 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACVLNILCPUHZOJH3KUTNJLRKRNDVANCNFSM4KPCFOEA>
.
|
@XhmikosR yep and I think we can avoid to have this system requirement by using a dev deps |
Feel free to suggest another patch. The less dependencies the better for me. |
1db5c2f
to
5ccfa2e
Compare
5ccfa2e
to
97019b8
Compare
97019b8
to
5b558c3
Compare
I'm gonna merge this as a first patch. Everyone can improve later as needed 🙂 |
Fixes #30076
Preview: https://deploy-preview-30130--twbs-bootstrap.netlify.com/docs/4.3/examples/
TODO:
links
andscript
tags, nota
tags