Skip to content

Commit

Permalink
fix(xq): adopt xq file name convention
Browse files Browse the repository at this point in the history
close #614

BREAKING CHANGE: File name changes require exist-db 5.3 min version
  • Loading branch information
duncdrum committed Sep 16, 2021
1 parent 26e6f19 commit 5a8a760
Show file tree
Hide file tree
Showing 18 changed files with 45 additions and 45 deletions.
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,30 +88,30 @@ Since if would be impractical to go through all possible combinations of option
├── LICENSE
├── README.md
├── admin
│   ├── controller.xql
│   ├── controller.xq
│   ├── index.html
│   └── security.html
├── build
│   ├── exide_demo-1.0.0-dev.xar
│   └── exide_demo-1.0.0.xar
├── build.xml
├── collection.xconf
├── controller.xql
├── controller.xq
├── cypress.json
├── error-page.html
├── expath-pkg.xml
├── icon.png
├── index.html
├── modules
│   ├── app.xql
│   ├── app.xqm
│   ├── config.xqm
│   └── view.xql
├── node_modules
│   └── pruned …
├── package-lock.json
├── package.json
├── post-install.xql
├── pre-install.xql
├── post-install.xq
├── pre-install.xq
├── repo.xml
├── reports
│   ├── screenshots
Expand Down Expand Up @@ -160,7 +160,7 @@ Since if would be impractical to go through all possible combinations of option
│   └── rest_spec.js
└── xqs
├── test-runner.xq
├── test-suite.xql
├── test-suite.xqm
└── xqSuite.js
```

Expand All @@ -174,22 +174,22 @@ Since if would be impractical to go through all possible combinations of option
│   └── plain_demo-1.0.0.xar
├── build.xml
├── collection.xconf
├── controller.xql
├── controller.xq
├── cypress.json
├── error-page.html
├── expath-pkg.xml
├── icon.png
├── index.html
├── modules
│   ├── app.xql
│   ├── app.xqm
│   ├── config.xqm
│   └── view.xql
├── node_modules
│   └── pruned …
├── package-lock.json
├── package.json
├── post-install.xql
├── pre-install.xql
├── post-install.xq
├── pre-install.xq
├── repo.xml
├── reports
│   ├── screenshots
Expand All @@ -215,7 +215,7 @@ Since if would be impractical to go through all possible combinations of option
│   └── rest_spec.js
└── xqs
├── test-runner.xq
├── test-suite.xql
├── test-suite.xqm
└── xqSuite.js
```

Expand Down Expand Up @@ -254,7 +254,7 @@ Since if would be impractical to go through all possible combinations of option
│   └── rest_spec.js
└── xqs
├── test-runner.xq
├── test-suite.xql
├── test-suite.xqm
└── xqSuite.js
```

Expand All @@ -272,16 +272,16 @@ Since if would be impractical to go through all possible combinations of option
│   └── pruned …
├── package-lock.json
├── package.json
├── post-install.xql
├── pre-install.xql
├── post-install.xq
├── pre-install.xq
├── repo.xml
└── test
├── mocha
│   ├── app_spec.js
│   └── rest_spec.js
└── xqs
├── test-runner.xq
├── test-suite.xql
├── test-suite.xqm
└── xqSuite.js
```

Expand Down
26 changes: 13 additions & 13 deletions generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ module.exports = class extends Generator {
type: 'confirm',
name: 'post',
message: 'Would you like to generate a post-install script?',
default: 'post-install.xql'
default: 'post-install.xq'
},
// TODO multi authors see #41
{
Expand Down Expand Up @@ -414,9 +414,9 @@ module.exports = class extends Generator {
apptype: this.props.apptype[1],
status: this.props.status,
pre: this.props.pre,
prexq: 'pre-install.xql',
prexq: 'pre-install.xq',
post: this.props.post,
postxq: 'post-install.xql',
postxq: 'post-install.xq',
setperm: this.props.setperm,
website: this.props.website,
license: this.props.license[0],
Expand All @@ -439,8 +439,8 @@ module.exports = class extends Generator {

// Unit Test
this.fs.copyTpl(
this.templatePath('specs/xqs/test-suite.xql'),
this.destinationPath('test/xqs/test-suite.xql'), {
this.templatePath('specs/xqs/test-suite.xqm'),
this.destinationPath('test/xqs/test-suite.xqm'), {
apptype: this.props.apptype[0],
short: this.props.short,
defcoll: this.props.defcoll,
Expand Down Expand Up @@ -553,8 +553,8 @@ module.exports = class extends Generator {

// XQuery
this.fs.copyTpl(
this.templatePath('xq/controller.xql'),
this.destinationPath('controller.xql'), {
this.templatePath('xq/controller.xq'),
this.destinationPath('controller.xq'), {
apptype: this.props.apptype[0],
mysec: this.props.mysec
})
Expand All @@ -569,8 +569,8 @@ module.exports = class extends Generator {
version: this.props.version
})
this.fs.copyTpl(
this.templatePath('xq/app.xql'),
this.destinationPath('modules/app.xql'), {
this.templatePath('xq/app.xqm'),
this.destinationPath('modules/app.xqm'), {
short: this.props.short,
defcoll: this.props.defcoll,
defuri: this.props.defuri,
Expand Down Expand Up @@ -643,8 +643,8 @@ module.exports = class extends Generator {
// Pre-install
if (this.props.pre) {
this.fs.copyTpl(
this.templatePath('xq/pre-install.xql'),
this.destinationPath('pre-install.xql'), {
this.templatePath('xq/pre-install.xq'),
this.destinationPath('pre-install.xq'), {
version: this.props.version,
author: this.props.author,
website: this.props.website
Expand All @@ -654,8 +654,8 @@ module.exports = class extends Generator {
// Post-install
if (this.props.post) {
this.fs.copyTpl(
this.templatePath('xq/post-install.xql'),
this.destinationPath('post-install.xql'), {
this.templatePath('xq/post-install.xq'),
this.destinationPath('post-install.xq'), {
apptype: this.props.apptype[0],
version: this.props.version,
author: this.props.author,
Expand Down
2 changes: 1 addition & 1 deletion generators/app/templates/expath-pkg.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<package xmlns="http://expath.org/ns/pkg" name="<%- defuri %>/<%- defcoll %>/<%- short %>"
abbrev="<%- short %>" version="<%- version %>" spec="1.0">
<title><%- desc %></title>
<dependency processor="http://exist-db.org" semver-min="5.0.0"/>
<dependency processor="http://exist-db.org" semver-min="5.3.0"/>
<%_ if (apptype !== 'empty') { %><dependency package="http://exist-db.org/html-templating" semver-min="1.0.2"/><% } -%>
</package>
2 changes: 1 addition & 1 deletion generators/app/templates/pages/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ <h1 data-template="config:app-title">Generated page</h1>
<p>
This is the entry page into your application and was generated by yeoman. It uses HTML templates for a clean separation of HTML views and application logic.</p>
<p>To add your own template functions, start by editing the XQuery module:
<pre>app.xql</pre>.</p>
<pre>app.xqm</pre>.</p>
</div>
<div class="row">
<div class="col-md-6">
Expand Down
2 changes: 1 addition & 1 deletion generators/app/templates/specs/integration/landing_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ describe('The landing page', function () {
it <%_ if (apptype == 'empty') { %>.skip <% } _%> ('should load ', function () {
cy.visit('/exist/<%- defcoll %>/<%- short %>/index.html')
.get('.alert')
.contains('app.xql')
.contains('app.xqm')
})

<%_ if (mysec) { %>
Expand Down
4 changes: 2 additions & 2 deletions generators/app/templates/specs/xqs/test-runner.xq
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ xquery version "3.1";
: @see http://www.exist-db.org/exist/apps/doc/xqsuite
:)
import module namespace test="http://exist-db.org/xquery/xqsuite" at "resource:org/exist/xquery/lib/xqsuite/xqsuite.xql";
import module namespace tests="<%- defuri %>/<%- defcoll %>/<%- short %>/tests" at "test-suite.xql";
import module namespace tests="<%- defuri %>/<%- defcoll %>/<%- short %>/tests" at "test-suite.xqm";

declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";
declare option output:method "json";
declare option output:media-type "application/json";

test:suite(
inspect:module-functions(xs:anyURI("test-suite.xql"))
inspect:module-functions(xs:anyURI("test-suite.xqm"))
)
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ xquery version "3.1";

module namespace tests = "<%- defuri %>/<%- defcoll %>/<%- short %>/tests";
<%_ if (apptype !== 'empty') { %>
import module namespace app = "<%- defuri %>/<%- defcoll %>/<%- short %>/templates" at "../../modules/app.xql";
import module namespace app = "<%- defuri %>/<%- defcoll %>/<%- short %>/templates" at "../../modules/app.xqm";
<% } -%>

declare namespace test="http://exist-db.org/xquery/xqsuite";
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions generators/app/templates/xq/view.xql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(:~
: This is the main XQuery which will (by default) be called by controller.xql
: This is the main XQuery which will (by default) be called by controller.xq
: to process any URI ending with ".html". It receives the HTML from
: the controller and passes it to the templating system.
:
Expand All @@ -16,7 +16,7 @@ import module namespace lib="http://exist-db.org/xquery/html-templating/lib";
:)

import module namespace config="<%- defuri %>/<%- defcoll %>/<%- short %>/config" at "config.xqm";
import module namespace app="<%- defuri %>/<%- defcoll %>/<%- short %>/templates" at "app.xql";
import module namespace app="<%- defuri %>/<%- defcoll %>/<%- short %>/templates" at "app.xqm";


declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
Expand Down
4 changes: 2 additions & 2 deletions test/generated-pkg/app-eXide-default.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('eXide style …', function () {

describe('exist design has …', function () {
it('default files', function (done) {
assert.file(['repo.xml', 'modules/app.xql', 'post-install.xql', 'pre-install.xql', 'test/xqs/test-suite.xql'])
assert.file(['repo.xml', 'modules/app.xqm', 'post-install.xq', 'pre-install.xq', 'test/xqs/test-suite.xqm'])
done()
})

Expand Down Expand Up @@ -72,7 +72,7 @@ describe('eXide style …', function () {

// Checking Xquery files requires updates to xqlint
// it('linted XQuery', function () {
// let xq = fs.readFileSync('modules/app.xql')
// let xq = fs.readFileSync('modules/app.xqm')
// let xql = new xmldoc.XmlDocument(xq).toString()
// expect(doc).xml.to.be.valid()
// })
Expand Down
4 changes: 2 additions & 2 deletions test/generated-pkg/app-eXide-plain.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ describe('eXide plain app', function () {
admin: 'admin',
adminpw: 'pw123'
})
assert.noFile(['resources/images/bold.gif', 'pre-install.xql', 'test/cypress/integration/secure_spec.js', '.travis.yml', 'resources/css/exist-2.2.css'])
assert.noFile(['resources/images/bold.gif', 'pre-install.xq', 'test/cypress/integration/secure_spec.js', '.travis.yml', 'resources/css/exist-2.2.css'])
})

describe('plain package has', function () {
it('recommended files', function (done) {
assert.file(['expath-pkg.xml', 'modules/config.xqm', 'test/xqs/test-runner.xq', 'controller.xql', '.dockerignore', 'resources/images/powered-by.svg'])
assert.file(['expath-pkg.xml', 'modules/config.xqm', 'test/xqs/test-runner.xq', 'controller.xq', '.dockerignore', 'resources/images/powered-by.svg'])
done()
})

Expand Down
2 changes: 1 addition & 1 deletion test/generated-pkg/app-empty.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('empty package', function () {
github: false,
atom: false
})
assert.noFile(['modules/app.xql', 'templates/page.html', 'test/cypress/integration/login-ok_spec.js', 'index.html'])
assert.noFile(['modules/app.xqm', 'templates/page.html', 'test/cypress/integration/login-ok_spec.js', 'index.html'])
})

describe('empty has', function () {
Expand Down
6 changes: 3 additions & 3 deletions test/generated-pkg/app-lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ describe('library package', function () {
atom: false,
ci: 'travis'
})
assert.noFile(['modules/app.xql', 'modules/test-suite.xql', 'templates/page.html', 'reports/screenshots/.gitkeep', 'controller.xql', 'collection.xconf'])
assert.noFile(['modules/app.xqm', 'modules/test-suite.xqm', 'templates/page.html', 'reports/screenshots/.gitkeep', 'controller.xq', 'collection.xconf'])
})

describe('library has', function () {
it('only recommended files', function (done) {
assert.file(['repo.xml', 'README.md', '.git/config', '.gitignore', 'test/xqs/test-suite.xql'])
assert.file(['repo.xml', 'README.md', '.git/config', '.gitignore', 'test/xqs/test-suite.xqm'])
done()
})

Expand All @@ -51,7 +51,7 @@ describe('library package', function () {
})

it('xqs does not call app module', function (done) {
assert.noFileContent('test/xqs/test-suite.xql', 'import module namespace app')
assert.noFileContent('test/xqs/test-suite.xqm', 'import module namespace app')
done()
})

Expand Down
2 changes: 1 addition & 1 deletion test/generated-pkg/app-mysec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('eXide style …', function () {

describe('secure exist design has …', function () {
it('default files and restricted area', function (done) {
assert.file(['admin/controller.xql', 'admin/index.html', 'templates/login-panel.html', 'pre-install.xql', 'test/cypress/integration/login-ok_spec.js'])
assert.file(['admin/controller.xq', 'admin/index.html', 'templates/login-panel.html', 'pre-install.xq', 'test/cypress/integration/login-ok_spec.js'])
done()
})

Expand Down

0 comments on commit 5a8a760

Please sign in to comment.