metanorma-cli 1.1.6 → 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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
@@ -0,0 +1,78 @@
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
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "metanorma-cli"
4
+ gem "relaton-cli"
@@ -0,0 +1,126 @@
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
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,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
@@ -0,0 +1,78 @@
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
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.6
4
+ version: 1.1.7
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-03-23 00:00:00.000000000 Z
11
+ date: 2019-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '3.4'
111
+ - !ruby/object:Gem::Dependency
112
+ name: thor
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 0.20.3
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.20.3
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: metanorma-iso
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -332,6 +346,20 @@ dependencies:
332
346
  - - ">="
333
347
  - !ruby/object:Gem::Version
334
348
  version: '1'
349
+ - !ruby/object:Gem::Dependency
350
+ name: git
351
+ requirement: !ruby/object:Gem::Requirement
352
+ requirements:
353
+ - - "~>"
354
+ - !ruby/object:Gem::Version
355
+ version: '1.5'
356
+ type: :runtime
357
+ prerelease: false
358
+ version_requirements: !ruby/object:Gem::Requirement
359
+ requirements:
360
+ - - "~>"
361
+ - !ruby/object:Gem::Version
362
+ version: '1.5'
335
363
  description: Executable to process any Metanorma standard.
336
364
  email:
337
365
  - open.source@ribose.com
@@ -354,6 +382,7 @@ files:
354
382
  - a.rb
355
383
  - appveyor.yml
356
384
  - bin/console
385
+ - bin/rspec
357
386
  - bin/setup
358
387
  - csd-tofix 2.zip
359
388
  - csd-tofix.zip
@@ -364,10 +393,37 @@ files:
364
393
  - i18n.yaml
365
394
  - lib/metanorma-cli.rb
366
395
  - lib/metanorma/cli.rb
396
+ - lib/metanorma/cli/command.rb
397
+ - lib/metanorma/cli/compiler.rb
398
+ - lib/metanorma/cli/generator.rb
399
+ - lib/metanorma/cli/git_template.rb
400
+ - lib/metanorma/cli/ui.rb
367
401
  - lib/metanorma/cli/version.rb
368
402
  - metanorma-cli.gemspec
369
403
  - sourcecode/0
404
+ - templates/base/Gemfile
405
+ - templates/base/Makefile
406
+ - templates/base/Makefile.win
407
+ - templates/base/appveyor.yml
408
+ - templates/base/deploy.sh
409
+ - templates/csd/LICENSE
410
+ - templates/csd/collection/Makefile
411
+ - templates/csd/common/Gemfile
412
+ - templates/csd/common/Makefile
413
+ - templates/csd/common/Makefile.win
414
+ - templates/csd/common/appveyor.yml
415
+ - templates/csd/common/deploy.sh
370
416
  - test.rxl
417
+ - tmp/my-custom-csd/Gemfile
418
+ - tmp/my-custom-csd/Makefile
419
+ - tmp/my-custom-csd/Makefile.win
420
+ - tmp/my-custom-csd/appveyor.yml
421
+ - tmp/my-custom-csd/deploy.sh
422
+ - tmp/my-document/Gemfile
423
+ - tmp/my-document/Makefile
424
+ - tmp/my-document/Makefile.win
425
+ - tmp/my-document/appveyor.yml
426
+ - tmp/my-document/deploy.sh
371
427
  homepage: https://www.metanorma.com
372
428
  licenses:
373
429
  - BSD-2-Clause