apostrophe 2.224.0 → 2.225.0-alpha

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## UNRELEASED
4
+
5
+ ### Adds
6
+
7
+ * Accepts `APOS_BASE_URL` environment variable as an override of the global `baseUrl` option. Useful in devops.
8
+
3
9
  ## 2.224.0 (2023-02-01)
4
10
 
5
11
  ### Adds
package/index.js CHANGED
@@ -335,6 +335,8 @@ module.exports = function(options) {
335
335
  throw "Specify the `shortName` option and set it to the name of your project's repository or folder";
336
336
  }
337
337
  self.title = self.options.title;
338
+ // For devops purposes
339
+ self.options.baseUrl = process.env.APOS_BASE_URL || self.options.baseUrl;
338
340
  self.baseUrl = self.options.baseUrl;
339
341
  self.prefix = self.options.prefix || '';
340
342
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apostrophe",
3
- "version": "2.224.0",
3
+ "version": "2.225.0-alpha",
4
4
  "description": "The Apostrophe Content Management System.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -0,0 +1,45 @@
1
+ const t = require('../test-lib/test.js');
2
+ const assert = require('assert');
3
+ let apos;
4
+ let savedBaseUrl;
5
+
6
+ describe('APOS_BASE_URL environment variable', function() {
7
+
8
+ this.timeout(t.timeout);
9
+
10
+ before(function(done) {
11
+ savedBaseUrl = process.env.APOS_BASE_URL;
12
+ process.env.APOS_BASE_URL = 'https://madethisup.com';
13
+ apos = require('../index.js')({
14
+ root: module,
15
+ shortName: 'test',
16
+ afterInit: function(callback) {
17
+ // In tests this will be the name of the test file,
18
+ // so override that in order to get apostrophe to
19
+ // listen normally and not try to run a task. -Tom
20
+ apos.argv._ = [];
21
+ return callback(null);
22
+ },
23
+ afterListen: function(err) {
24
+ assert(!err);
25
+ done();
26
+ }
27
+ });
28
+ });
29
+
30
+ after(function(done) {
31
+ if (savedBaseUrl) {
32
+ process.env.APOS_BASE_URL = savedBaseUrl;
33
+ } else {
34
+ delete process.env.APOS_BASE_URL;
35
+ }
36
+ return t.destroy(apos, done);
37
+ });
38
+
39
+ it('should respect APOS_BASE_URL', async function() {
40
+ const req = apos.tasks.getReq();
41
+ const home = await apos.docs.find(req, { slug: '/' }).toObject();
42
+ assert(home);
43
+ assert.strictEqual(home._url, 'https://madethisup.com/');
44
+ });
45
+ });