metanorma-cli 1.1.7 → 1.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8fa38ce1860b4256de0f9b4ce25208f31163d83868104767c173f506297613fa
4
- data.tar.gz: 90b8fbd71d13c04c842152a4c3e398e2a8764f9e146ca108c060554248e82f60
3
+ metadata.gz: 17e6241712028d756a1aa8fbfdb9071f430850fc70095eb7899c5040a32286fa
4
+ data.tar.gz: c338a1af3c9eaf0adaafb61581df07d8e579cdb690face35fd0d5717e27ea81e
5
5
  SHA512:
6
- metadata.gz: bcd81d875a2284810beb475c6034968119c135a8bc972ca5d09a57157c9d22c7c3e9c780867a6b1bf37675c1fc81cb6c1291460e868dd2e34b3e3a088be83815
7
- data.tar.gz: 3019e193d3e6d9ece09644a965419f49470f6404de69e1c5e8726536cbc0581649f7ebaa6f7bec40798867c0f2f2a4b37b61a89586dd4212f6a391c5c168e1b1
6
+ metadata.gz: a84bb780427cd9cc7f4ac9c45dee1b2dd4a9a7ac30ee8d2eda5ba896c847c26595e3f323b124b867c2f50b36c7f26ee3be4fe590897d669c8cc6d13a6d64b83b
7
+ data.tar.gz: b5dc3027dfa5525d840745c30a5fa4f12f83bf9cb3d03eae2260568603e7c65d795fa7226cc018c9255e82c6b27bc9067728a80cde5db101d21bb122e0c3f188
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- metanorma-cli (1.1.7)
4
+ metanorma-cli (1.1.8)
5
5
  git (~> 1.5)
6
6
  isodoc (~> 0.9.0)
7
7
  metanorma (~> 0.3.9)
@@ -73,7 +73,7 @@ GEM
73
73
  algoliasearch
74
74
  iecbib (~> 0.2.1)
75
75
  iso-bib-item (~> 0.4.2)
76
- isodoc (0.9.22)
76
+ isodoc (0.9.23)
77
77
  asciimath
78
78
  html2doc (~> 0.8.6)
79
79
  htmlentities (~> 4.3.4)
@@ -121,7 +121,7 @@ GEM
121
121
  metanorma-ietf (1.0.1)
122
122
  isodoc (~> 0.9.6)
123
123
  metanorma-standoc (~> 1.1.0)
124
- metanorma-iso (1.1.5)
124
+ metanorma-iso (1.1.6)
125
125
  asciidoctor (~> 1.5.7)
126
126
  iev (~> 0.2.0)
127
127
  isodoc (~> 0.9.8)
@@ -166,7 +166,7 @@ GEM
166
166
  isodoc (~> 0.9.0)
167
167
  metanorma-standoc (~> 1.1.0)
168
168
  nokogiri
169
- metanorma-standoc (1.1.8)
169
+ metanorma-standoc (1.1.9)
170
170
  asciidoctor (~> 1.5.7)
171
171
  concurrent-ruby
172
172
  html2doc (~> 0.8.0)
@@ -190,8 +190,8 @@ GEM
190
190
  mime-types-data (3.2019.0331)
191
191
  mini_portile2 (2.3.0)
192
192
  mixlib-shellout (2.4.4)
193
- nistbib (0.1.2)
194
- iso-bib-item (~> 0.4.2)
193
+ nistbib (0.1.5)
194
+ relaton-bib (~> 0.1.0)
195
195
  nokogiri (1.8.5)
196
196
  mini_portile2 (~> 2.3.0)
197
197
  optout (0.0.2)
@@ -208,6 +208,8 @@ GEM
208
208
  iso-bib-item (~> 0.4.2)
209
209
  isobib (~> 0.4.0)
210
210
  nistbib (~> 0.1.1)
211
+ relaton-bib (0.1.1)
212
+ nokogiri (~> 1.8.4)
211
213
  roman-numerals (0.3.0)
212
214
  rspec (3.8.0)
213
215
  rspec-core (~> 3.8.0)
@@ -54,14 +54,31 @@ module Metanorma
54
54
  end
55
55
 
56
56
  Metanorma::Cli::Command.start(arguments)
57
+
58
+ rescue Errno::ENOENT => error
59
+ UI.say("Error: #{error}, \nNot sure what to run? try: metanorma help")
57
60
  end
58
61
 
59
62
  def self.root
60
63
  File.dirname(__dir__)
61
64
  end
62
65
 
66
+ def self.base_templates_path
67
+ root_path.join("templates", "base")
68
+ end
69
+
63
70
  def self.templates_path
64
- root_path.join("templates")
71
+ Pathname.new(Dir.home).join(".metanorma", "templates")
72
+ end
73
+
74
+ def self.writable_templates_path?
75
+ parent_directory = templates_path.join("..", "..")
76
+
77
+ unless parent_directory && parent_directory.writable?
78
+ raise Errno::EACCES, "No permission to write in this drectory"
79
+ end
80
+
81
+ return true
65
82
  end
66
83
 
67
84
  def self.root_path
@@ -10,7 +10,7 @@ module Metanorma
10
10
  option :type, aliases: "-t", required: true, desc: "Document type"
11
11
  option :doctype, aliases: "-d", required: true, desc: "Metanorma doctype"
12
12
  option :overwrite, aliases: "-r", desc: "Overwrite existing document"
13
- option :template, aliases: "-g", desc: "Git hosted remote template skeleton"
13
+ option :template, aliases: "-l", desc: "Git hosted remote or local FS template skeleton"
14
14
 
15
15
  def new(name)
16
16
  create_new_document(name, options.dup)
@@ -1,3 +1,4 @@
1
+ require "uri"
1
2
  require "pathname"
2
3
  require "fileutils"
3
4
  require "metanorma/cli/ui"
@@ -10,15 +11,21 @@ module Metanorma
10
11
  @type = type
11
12
  @doctype = doctype
12
13
  @options = options
14
+ @template = options.fetch(:template, nil)
13
15
  end
14
16
 
15
17
  def run
16
- if name && document_path.exist?
17
- return unless overwrite?(document_path)
18
- document_path.rmtree
18
+ if Cli.writable_templates_path?
19
+ if name && document_path.exist?
20
+ return unless overwrite?(document_path)
21
+ document_path.rmtree
22
+ end
23
+
24
+ create_metanorma_document
19
25
  end
20
26
 
21
- create_metanorma_document
27
+ rescue Errno::EACCES
28
+ permission_missing_error
22
29
  end
23
30
 
24
31
  # Generator.run
@@ -37,7 +44,7 @@ module Metanorma
37
44
 
38
45
  private
39
46
 
40
- attr_reader :name, :type, :doctype, :options
47
+ attr_reader :name, :type, :doctype, :options, :template
41
48
 
42
49
  def document_path
43
50
  @document_path ||= Pathname.pwd.join(name)
@@ -57,7 +64,7 @@ module Metanorma
57
64
  end
58
65
  end
59
66
 
60
- def find_template(type)
67
+ def find_standard_template(type)
61
68
  Cli::GitTemplate.find_or_download_by(type)
62
69
  end
63
70
 
@@ -66,19 +73,23 @@ module Metanorma
66
73
  end
67
74
 
68
75
  def base_templates
69
- base_template_root = Cli.templates_path.join("base")
76
+ base_template_root = Cli.base_templates_path
70
77
  build_template_hash(dir_files(base_template_root), base_template_root)
71
78
  end
72
79
 
73
80
  def type_specific_template
74
- type_template_path = custom_template || find_template(type)
81
+ type_template_path = custom_template || find_standard_template(type)
75
82
  doctype_templates = dir_files(type_template_path, doctype)
76
83
  build_template_hash(doctype_templates, type_template_path, doctype)
77
84
  end
78
85
 
79
86
  def custom_template
80
- if options[:template]
81
- Cli::GitTemplate.download(type, repo: options[:template])
87
+ if template
88
+ if template !~ URI::regexp
89
+ return Pathname.new(template)
90
+ end
91
+
92
+ Cli::GitTemplate.download(type, repo: template)
82
93
  end
83
94
  end
84
95
 
@@ -106,7 +117,9 @@ module Metanorma
106
117
 
107
118
  def dir_files(*arguments)
108
119
  paths = [*arguments, "**", "**"].join("/")
109
- Pathname.glob(paths).reject(&:directory?).map(&:to_s)
120
+ files = Pathname.glob(paths, File::FNM_DOTMATCH) - [".", " .."]
121
+
122
+ files.reject(&:directory?).map(&:to_s)
110
123
  end
111
124
 
112
125
  def ask_to_confirm(document)
@@ -119,6 +132,14 @@ module Metanorma
119
132
  def file_creation_message(document, destination)
120
133
  UI.say("Creating #{[document, destination].join("/").gsub("//", "/")}")
121
134
  end
135
+
136
+ def permission_missing_error
137
+ UI.say(
138
+ "Sorry, the current user doesn't have write permission\n" \
139
+ "to #{Cli.templates_path}. Please change it to be writable or\n" \
140
+ "run metanorma as different user with write permission to this path",
141
+ )
142
+ end
122
143
  end
123
144
  end
124
145
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Cli
3
- VERSION = "1.1.7"
3
+ VERSION = "1.1.8"
4
4
  end
5
5
  end
@@ -115,12 +115,3 @@ publish:
115
115
  cp -a $(basename $(SRC)).* published/ && \
116
116
  cp $(firstword $(HTML)) published/index.html; \
117
117
  if [ -d "images" ]; then cp -a images published; fi
118
-
119
- deploy_key:
120
- openssl aes-256-cbc -K $(encrypted_$(ENCRYPTION_LABEL)_key) \
121
- -iv $(encrypted_$(ENCRYPTION_LABEL)_iv) -in $@.enc -out $@ -d && \
122
- chmod 600 $@
123
-
124
- deploy: deploy_key
125
- export COMMIT_AUTHOR_EMAIL=$(COMMIT_AUTHOR_EMAIL); \
126
- ./deploy.sh
@@ -115,12 +115,3 @@ publish:
115
115
  cp -a $(basename $(SRC)).* published/ && \
116
116
  cp $(firstword $(HTML)) published/index.html; \
117
117
  if [ -d "images" ]; then cp -a images published; fi
118
-
119
- deploy_key:
120
- openssl aes-256-cbc -K $(encrypted_$(ENCRYPTION_LABEL)_key) \
121
- -iv $(encrypted_$(ENCRYPTION_LABEL)_iv) -in $@.enc -out $@ -d && \
122
- chmod 600 $@
123
-
124
- deploy: deploy_key
125
- export COMMIT_AUTHOR_EMAIL=$(COMMIT_AUTHOR_EMAIL); \
126
- ./deploy.sh
@@ -115,12 +115,3 @@ publish:
115
115
  cp -a $(basename $(SRC)).* published/ && \
116
116
  cp $(firstword $(HTML)) published/index.html; \
117
117
  if [ -d "images" ]; then cp -a images published; fi
118
-
119
- deploy_key:
120
- openssl aes-256-cbc -K $(encrypted_$(ENCRYPTION_LABEL)_key) \
121
- -iv $(encrypted_$(ENCRYPTION_LABEL)_iv) -in $@.enc -out $@ -d && \
122
- chmod 600 $@
123
-
124
- deploy: deploy_key
125
- export COMMIT_AUTHOR_EMAIL=$(COMMIT_AUTHOR_EMAIL); \
126
- ./deploy.sh
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "metanorma-cli"
4
+ gem "relaton-cli"
@@ -0,0 +1,117 @@
1
+ #!make
2
+ SHELL := /bin/bash
3
+
4
+ FORMAT_MARKER := mn-output-
5
+ FORMATS := $(shell grep "$(FORMAT_MARKER)" *.adoc | cut -f 2 -d ' ' | tr ',' '\n' | sort | uniq | tr '\n' ' ')
6
+
7
+ SRC := $(filter-out README.adoc, $(wildcard *.adoc))
8
+ XML := $(patsubst %.adoc,%.xml,$(SRC))
9
+ HTML := $(patsubst %.adoc,%.html,$(SRC))
10
+ DOC := $(patsubst %.adoc,%.doc,$(SRC))
11
+ PDF := $(patsubst %.adoc,%.pdf,$(SRC))
12
+ WSD := $(wildcard models/*.wsd)
13
+ XMI := $(patsubst models/%,xmi/%,$(patsubst %.wsd,%.xmi,$(WSD)))
14
+ PNG := $(patsubst models/%,images/%,$(patsubst %.wsd,%.png,$(WSD)))
15
+
16
+ COMPILE_CMD_LOCAL := bundle exec metanorma $$FILENAME
17
+ COMPILE_CMD_DOCKER := docker run -v "$$(pwd)":/metanorma/ ribose/metanorma "metanorma $$FILENAME"
18
+
19
+ ifdef METANORMA_DOCKER
20
+ COMPILE_CMD := echo "Compiling via docker..."; $(COMPILE_CMD_DOCKER)
21
+ else
22
+ COMPILE_CMD := echo "Compiling locally..."; $(COMPILE_CMD_LOCAL)
23
+ endif
24
+
25
+ _OUT_FILES := $(foreach FORMAT,$(FORMATS),$(shell echo $(FORMAT) | tr '[:lower:]' '[:upper:]'))
26
+ OUT_FILES := $(foreach F,$(_OUT_FILES),$($F))
27
+
28
+ all: images $(OUT_FILES)
29
+
30
+ %.xml %.html %.doc %.pdf: %.adoc | bundle
31
+ FILENAME=$^; \
32
+ ${COMPILE_CMD}
33
+
34
+ images: $(PNG)
35
+
36
+ images/%.png: models/%.wsd
37
+ plantuml -tpng -o ../images/ $<
38
+
39
+ xmi: $(XMI)
40
+
41
+ xmi/%.xmi: models/%.wsd
42
+ plantuml -xmi:star -o ../xmi/ $<
43
+
44
+ define FORMAT_TASKS
45
+ OUT_FILES-$(FORMAT) := $($(shell echo $(FORMAT) | tr '[:lower:]' '[:upper:]'))
46
+
47
+ open-$(FORMAT):
48
+ open $$(OUT_FILES-$(FORMAT))
49
+
50
+ clean-$(FORMAT):
51
+ rm -f $$(OUT_FILES-$(FORMAT))
52
+
53
+ $(FORMAT): clean-$(FORMAT) $$(OUT_FILES-$(FORMAT))
54
+
55
+ .PHONY: clean-$(FORMAT)
56
+
57
+ endef
58
+
59
+ $(foreach FORMAT,$(FORMATS),$(eval $(FORMAT_TASKS)))
60
+
61
+ open: open-html
62
+
63
+ clean:
64
+ rm -f $(OUT_FILES)
65
+
66
+ bundle:
67
+ if [ "x" == "${METANORMA_DOCKER}x" ]; then bundle; fi
68
+
69
+ .PHONY: bundle all open clean
70
+
71
+ #
72
+ # Watch-related jobs
73
+ #
74
+
75
+ .PHONY: watch serve watch-serve
76
+
77
+ NODE_BINS := onchange live-serve run-p
78
+ NODE_BIN_DIR := node_modules/.bin
79
+ NODE_PACKAGE_PATHS := $(foreach PACKAGE_NAME,$(NODE_BINS),$(NODE_BIN_DIR)/$(PACKAGE_NAME))
80
+
81
+ $(NODE_PACKAGE_PATHS): package.json
82
+ npm i
83
+
84
+ watch: $(NODE_BIN_DIR)/onchange
85
+ make all
86
+ $< $(ALL_SRC) -- make all
87
+
88
+ define WATCH_TASKS
89
+ watch-$(FORMAT): $(NODE_BIN_DIR)/onchange
90
+ make $(FORMAT)
91
+ $$< $$(SRC_$(FORMAT)) -- make $(FORMAT)
92
+
93
+ .PHONY: watch-$(FORMAT)
94
+ endef
95
+
96
+ $(foreach FORMAT,$(FORMATS),$(eval $(WATCH_TASKS)))
97
+
98
+ serve: $(NODE_BIN_DIR)/live-server revealjs-css reveal.js images
99
+ export PORT=$${PORT:-8123} ; \
100
+ port=$${PORT} ; \
101
+ for html in $(HTML); do \
102
+ $< --entry-file=$$html --port=$${port} --ignore="*.html,*.xml,Makefile,Gemfile.*,package.*.json" --wait=1000 & \
103
+ port=$$(( port++ )) ;\
104
+ done
105
+
106
+ watch-serve: $(NODE_BIN_DIR)/run-p
107
+ $< watch serve
108
+
109
+ #
110
+ # Deploy jobs
111
+ #
112
+
113
+ publish:
114
+ mkdir -p published && \
115
+ cp -a $(basename $(SRC)).* published/ && \
116
+ cp $(firstword $(HTML)) published/index.html; \
117
+ if [ -d "images" ]; then cp -a images published; fi
@@ -0,0 +1,63 @@
1
+ #!make
2
+
3
+ include metanorma.env
4
+ export $(shell sed 's/=.*//' metanorma.env)
5
+
6
+ FORMATS := $(METANORMA_FORMATS)
7
+ comma := ,
8
+ empty :=
9
+ space := $(empty) $(empty)
10
+
11
+ SRC := $(filter-out README.adoc, $(wildcard *.adoc))
12
+ XML := $(patsubst %.adoc,%.xml,$(SRC))
13
+ HTML := $(patsubst %.adoc,%.html,$(SRC))
14
+ DOC := $(patsubst %.adoc,%.doc,$(SRC))
15
+ PDF := $(patsubst %.adoc,%.pdf,$(SRC))
16
+ RXL := $(patsubst %.adoc,%.rxl,$(SRC))
17
+
18
+ HOST_SHARE_DIR=$(USERPROFILE)\$(shell for %%I in (.) do echo %%~nxI)
19
+ COMPILE_CMD_LOCAL := bundle exec metanorma -R $(RXL) $(SRC)
20
+ COMPILE_CMD_DOCKER := C:/ProgramData/chocolatey/bin/docker run --rm -it -v $(CURDIR):/metanorma/ ribose/metanorma "metanorma -R $(RXL) $(SRC)"
21
+
22
+ ifdef METANORMA_DOCKER
23
+ COMPILE_CMD := echo "Compiling via docker..." & $(COMPILE_CMD_DOCKER)
24
+ else
25
+ COMPILE_CMD := echo "Compiling locally..." & $(COMPILE_CMD_LOCAL)
26
+ endif
27
+
28
+ _OUT_FILES := $(foreach FORMAT,$(FORMATS),$(shell echo $(FORMAT) | tr '[:lower:]' '[:upper:]'))
29
+ OUT_FILES := $(foreach F,$(_OUT_FILES),$($F))
30
+
31
+ all: $(OUT_FILES)
32
+
33
+ %.xml %.html %.doc %.pdf: %.adoc | bundle
34
+ ${COMPILE_CMD}
35
+
36
+ define FORMAT_TASKS
37
+ OUT_FILES-$(FORMAT) := $($(shell echo $(FORMAT) | tr '[:lower:]' '[:upper:]'))
38
+
39
+ open-$(FORMAT):
40
+ $$(OUT_FILES-$(FORMAT))
41
+
42
+ clean-$(FORMAT):
43
+ rm $$(OUT_FILES-$(FORMAT))
44
+
45
+ $(FORMAT): clean-$(FORMAT) $$(OUT_FILES-$(FORMAT))
46
+
47
+ .PHONY: clean-$(FORMAT)
48
+
49
+ endef
50
+
51
+ $(foreach FORMAT,$(FORMATS),$(eval $(FORMAT_TASKS)))
52
+
53
+ # open: $(foreach FORMAT,$(FORMATS),open-$(FORMAT))
54
+
55
+ open: open-html
56
+
57
+ clean:
58
+ rm -rf $(OUT_FILES)
59
+
60
+ bundle:
61
+ IF "" == "${METANORMA_DOCKER}" bundle
62
+
63
+ .PHONY: bundle all open clean
@@ -0,0 +1,29 @@
1
+ version: '{build}'
2
+
3
+ environment:
4
+ matrix:
5
+ - RUBY_VERSION: 25
6
+ - RUBY_VERSION: 24
7
+ - RUBY_VERSION: _trunk
8
+
9
+ matrix:
10
+ allow_failures:
11
+ - RUBY_VERSION: _trunk
12
+
13
+ install:
14
+ - ps: . { iwr -useb https://raw.githubusercontent.com/metanorma/metanorma-build-scripts/master/appveyor.ps1 } | iex
15
+ - refreshenv
16
+
17
+ build_script:
18
+ - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH%
19
+ - bundle update
20
+ - bundle install
21
+
22
+ before_test:
23
+ - ruby -v
24
+ - gem -v
25
+ - bundle -v
26
+
27
+ test_script:
28
+ - plantuml -testdot
29
+ - make -f Makefile.win clean all publish SHELL=cmd
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.7
4
+ version: 1.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-04-25 00:00:00.000000000 Z
11
+ date: 2019-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -405,7 +405,6 @@ files:
405
405
  - templates/base/Makefile
406
406
  - templates/base/Makefile.win
407
407
  - templates/base/appveyor.yml
408
- - templates/base/deploy.sh
409
408
  - templates/csd/LICENSE
410
409
  - templates/csd/collection/Makefile
411
410
  - templates/csd/common/Gemfile
@@ -418,12 +417,14 @@ files:
418
417
  - tmp/my-custom-csd/Makefile
419
418
  - tmp/my-custom-csd/Makefile.win
420
419
  - tmp/my-custom-csd/appveyor.yml
421
- - tmp/my-custom-csd/deploy.sh
422
420
  - tmp/my-document/Gemfile
423
421
  - tmp/my-document/Makefile
424
422
  - tmp/my-document/Makefile.win
425
423
  - tmp/my-document/appveyor.yml
426
- - tmp/my-document/deploy.sh
424
+ - tmp/my-local-document/Gemfile
425
+ - tmp/my-local-document/Makefile
426
+ - tmp/my-local-document/Makefile.win
427
+ - tmp/my-local-document/appveyor.yml
427
428
  homepage: https://www.metanorma.com
428
429
  licenses:
429
430
  - BSD-2-Clause
@@ -1,78 +0,0 @@
1
- #!/bin/bash
2
- # TODO: replace this script when https://github.com/travis-ci/dpl/issues/694 is fixed
3
- # Taken from https://raw.githubusercontent.com/w3c/permissions/master/deploy.sh
4
- set -e # Exit with nonzero exit code if anything fails
5
-
6
- errx() {
7
- readonly __progname=$(basename ${BASH_SOURCE})
8
- echo -e "[${__progname}] $@" >&2
9
- exit 1
10
- }
11
-
12
- SOURCE_BRANCH="master"
13
- TARGET_BRANCH="gh-pages"
14
- KEY_NAME=$(pwd)/deploy_key
15
-
16
- main() {
17
-
18
- # Pull requests and commits to other branches shouldn't try to deploy, just build to verify
19
- if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_BRANCH" != "$SOURCE_BRANCH" ]; then
20
- echo "Not a Travis PR or not matching branch ($SOURCE_BRANCH); skipping deploy."
21
- exit 0
22
- fi
23
-
24
- [ -z "$COMMIT_AUTHOR_EMAIL" ] && \
25
- errx "No COMMIT_AUTHOR_EMAIL provided; it must be set."
26
-
27
- if [ ! -f ${KEY_NAME} ]; then
28
- errx "No ${KEY_NAME} file detected; is ${KEY_NAME}.enc decrypted?"
29
- fi
30
-
31
- # Save some useful information
32
- REPO=`git config remote.origin.url`
33
- SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:}
34
- SHA=`git rev-parse --verify HEAD`
35
- DEST_DIR=out
36
-
37
- # Clone the existing $TARGET_BRANCH for this repo into $DEST_DIR/
38
- # Create a new empty branch if gh-pages doesn't exist yet (should only happen on first deploy)
39
- # git clone $REPO $DEST_DIR
40
- git clone $REPO $DEST_DIR || errx "Unable to clone Git."
41
- pushd $DEST_DIR
42
- git checkout $TARGET_BRANCH || git checkout --orphan $TARGET_BRANCH || errx "Unable to checkout git."
43
- popd
44
-
45
- # Clean out existing contents in $TARGET_BRANCH clone
46
- rm -rf $DEST_DIR/* || exit 0
47
-
48
- # Adding contents within published/ to $DEST_DIR.
49
- cp -a published/* $DEST_DIR/ || exit 0
50
-
51
- # Now let's go have some fun with the cloned repo
52
- pushd $DEST_DIR
53
- git config user.name "Travis CI"
54
- git config user.email "$COMMIT_AUTHOR_EMAIL"
55
-
56
- # If there are no changes to the compiled out (e.g. this is a README update) then just bail.
57
- if [[ -z $(git status -s) ]]; then
58
- echo "No changes to the output on this push; exiting."
59
- exit 0
60
- fi
61
-
62
- git status
63
-
64
- # Commit the "changes", i.e. the new version.
65
- # The delta will show diffs between new and old versions.
66
- git add .
67
- git commit -m "Deploy to GitHub Pages: ${SHA}"
68
-
69
- eval `ssh-agent -s`
70
- ssh-add ${KEY_NAME}
71
-
72
- # Now that we're all set up, we can push.
73
- git push $SSH_REPO $TARGET_BRANCH || errx "Unable to push to git."
74
- }
75
-
76
- main "$@"
77
-
78
- exit 0
@@ -1,78 +0,0 @@
1
- #!/bin/bash
2
- # TODO: replace this script when https://github.com/travis-ci/dpl/issues/694 is fixed
3
- # Taken from https://raw.githubusercontent.com/w3c/permissions/master/deploy.sh
4
- set -e # Exit with nonzero exit code if anything fails
5
-
6
- errx() {
7
- readonly __progname=$(basename ${BASH_SOURCE})
8
- echo -e "[${__progname}] $@" >&2
9
- exit 1
10
- }
11
-
12
- SOURCE_BRANCH="master"
13
- TARGET_BRANCH="gh-pages"
14
- KEY_NAME=$(pwd)/deploy_key
15
-
16
- main() {
17
-
18
- # Pull requests and commits to other branches shouldn't try to deploy, just build to verify
19
- if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_BRANCH" != "$SOURCE_BRANCH" ]; then
20
- echo "Not a Travis PR or not matching branch ($SOURCE_BRANCH); skipping deploy."
21
- exit 0
22
- fi
23
-
24
- [ -z "$COMMIT_AUTHOR_EMAIL" ] && \
25
- errx "No COMMIT_AUTHOR_EMAIL provided; it must be set."
26
-
27
- if [ ! -f ${KEY_NAME} ]; then
28
- errx "No ${KEY_NAME} file detected; is ${KEY_NAME}.enc decrypted?"
29
- fi
30
-
31
- # Save some useful information
32
- REPO=`git config remote.origin.url`
33
- SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:}
34
- SHA=`git rev-parse --verify HEAD`
35
- DEST_DIR=out
36
-
37
- # Clone the existing $TARGET_BRANCH for this repo into $DEST_DIR/
38
- # Create a new empty branch if gh-pages doesn't exist yet (should only happen on first deploy)
39
- # git clone $REPO $DEST_DIR
40
- git clone $REPO $DEST_DIR || errx "Unable to clone Git."
41
- pushd $DEST_DIR
42
- git checkout $TARGET_BRANCH || git checkout --orphan $TARGET_BRANCH || errx "Unable to checkout git."
43
- popd
44
-
45
- # Clean out existing contents in $TARGET_BRANCH clone
46
- rm -rf $DEST_DIR/* || exit 0
47
-
48
- # Adding contents within published/ to $DEST_DIR.
49
- cp -a published/* $DEST_DIR/ || exit 0
50
-
51
- # Now let's go have some fun with the cloned repo
52
- pushd $DEST_DIR
53
- git config user.name "Travis CI"
54
- git config user.email "$COMMIT_AUTHOR_EMAIL"
55
-
56
- # If there are no changes to the compiled out (e.g. this is a README update) then just bail.
57
- if [[ -z $(git status -s) ]]; then
58
- echo "No changes to the output on this push; exiting."
59
- exit 0
60
- fi
61
-
62
- git status
63
-
64
- # Commit the "changes", i.e. the new version.
65
- # The delta will show diffs between new and old versions.
66
- git add .
67
- git commit -m "Deploy to GitHub Pages: ${SHA}"
68
-
69
- eval `ssh-agent -s`
70
- ssh-add ${KEY_NAME}
71
-
72
- # Now that we're all set up, we can push.
73
- git push $SSH_REPO $TARGET_BRANCH || errx "Unable to push to git."
74
- }
75
-
76
- main "$@"
77
-
78
- exit 0
@@ -1,78 +0,0 @@
1
- #!/bin/bash
2
- # TODO: replace this script when https://github.com/travis-ci/dpl/issues/694 is fixed
3
- # Taken from https://raw.githubusercontent.com/w3c/permissions/master/deploy.sh
4
- set -e # Exit with nonzero exit code if anything fails
5
-
6
- errx() {
7
- readonly __progname=$(basename ${BASH_SOURCE})
8
- echo -e "[${__progname}] $@" >&2
9
- exit 1
10
- }
11
-
12
- SOURCE_BRANCH="master"
13
- TARGET_BRANCH="gh-pages"
14
- KEY_NAME=$(pwd)/deploy_key
15
-
16
- main() {
17
-
18
- # Pull requests and commits to other branches shouldn't try to deploy, just build to verify
19
- if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_BRANCH" != "$SOURCE_BRANCH" ]; then
20
- echo "Not a Travis PR or not matching branch ($SOURCE_BRANCH); skipping deploy."
21
- exit 0
22
- fi
23
-
24
- [ -z "$COMMIT_AUTHOR_EMAIL" ] && \
25
- errx "No COMMIT_AUTHOR_EMAIL provided; it must be set."
26
-
27
- if [ ! -f ${KEY_NAME} ]; then
28
- errx "No ${KEY_NAME} file detected; is ${KEY_NAME}.enc decrypted?"
29
- fi
30
-
31
- # Save some useful information
32
- REPO=`git config remote.origin.url`
33
- SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:}
34
- SHA=`git rev-parse --verify HEAD`
35
- DEST_DIR=out
36
-
37
- # Clone the existing $TARGET_BRANCH for this repo into $DEST_DIR/
38
- # Create a new empty branch if gh-pages doesn't exist yet (should only happen on first deploy)
39
- # git clone $REPO $DEST_DIR
40
- git clone $REPO $DEST_DIR || errx "Unable to clone Git."
41
- pushd $DEST_DIR
42
- git checkout $TARGET_BRANCH || git checkout --orphan $TARGET_BRANCH || errx "Unable to checkout git."
43
- popd
44
-
45
- # Clean out existing contents in $TARGET_BRANCH clone
46
- rm -rf $DEST_DIR/* || exit 0
47
-
48
- # Adding contents within published/ to $DEST_DIR.
49
- cp -a published/* $DEST_DIR/ || exit 0
50
-
51
- # Now let's go have some fun with the cloned repo
52
- pushd $DEST_DIR
53
- git config user.name "Travis CI"
54
- git config user.email "$COMMIT_AUTHOR_EMAIL"
55
-
56
- # If there are no changes to the compiled out (e.g. this is a README update) then just bail.
57
- if [[ -z $(git status -s) ]]; then
58
- echo "No changes to the output on this push; exiting."
59
- exit 0
60
- fi
61
-
62
- git status
63
-
64
- # Commit the "changes", i.e. the new version.
65
- # The delta will show diffs between new and old versions.
66
- git add .
67
- git commit -m "Deploy to GitHub Pages: ${SHA}"
68
-
69
- eval `ssh-agent -s`
70
- ssh-add ${KEY_NAME}
71
-
72
- # Now that we're all set up, we can push.
73
- git push $SSH_REPO $TARGET_BRANCH || errx "Unable to push to git."
74
- }
75
-
76
- main "$@"
77
-
78
- exit 0