ember-cli-deploy-s3-index 1.3.1 → 3.0.0

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,40 @@
1
+ name: Continuous Integration
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+
7
+ jobs:
8
+ test:
9
+ name: Test
10
+ runs-on: ubuntu-latest
11
+ strategy:
12
+ matrix:
13
+ node-version: [14.x, 16.x, 18.x, 20.x]
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+ - name: Use Node.js ${{ matrix.node-version }}
17
+ uses: actions/setup-node@v2
18
+ with:
19
+ node-version: ${{ matrix.node-version }}
20
+ cache: 'yarn'
21
+ - run: yarn install
22
+ - run: yarn test
23
+
24
+ test-floating:
25
+ name: Floating Dependencies
26
+ runs-on: ubuntu-latest
27
+ strategy:
28
+ matrix:
29
+ node-version: [14.x, 16.x, 18.x, 20.x]
30
+ steps:
31
+ - uses: actions/checkout@v2
32
+ - name: Use Node.js ${{ matrix.node-version }}
33
+ uses: actions/setup-node@v2
34
+ with:
35
+ node-version: ${{ matrix.node-version }}
36
+ cache: 'yarn'
37
+ - name: install dependencies
38
+ run: yarn install --no-lockfile
39
+ - name: test
40
+ run: yarn test
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Change Log
2
2
 
3
+
4
+ ## 3.0.0 (2023-05-16)
5
+
6
+ #### :boom: Breaking Change
7
+ * [#133](https://github.com/ember-cli-deploy/ember-cli-deploy-s3-index/pull/133) Update node version requirements and dependencies ([@lukemelia](https://github.com/lukemelia))
8
+ * [#113](https://github.com/ember-cli-deploy/ember-cli-deploy-s3-index/pull/113) [breaking] Switch to Github Actions for CI ([@jrjohnson](https://github.com/jrjohnson))
9
+
10
+ #### :rocket: Enhancement
11
+ * [#130](https://github.com/ember-cli-deploy/ember-cli-deploy-s3-index/pull/130) Add support for didDeployMessage ([@jkeen](https://github.com/jkeen))
12
+ * [#119](https://github.com/ember-cli-deploy/ember-cli-deploy-s3-index/pull/119) Optimise activation speed ([@vitch](https://github.com/vitch))
13
+
14
+ #### Committers: 4
15
+ - Jeff Keen ([@jkeen](https://github.com/jkeen))
16
+ - Jon Johnson ([@jrjohnson](https://github.com/jrjohnson))
17
+ - Kelvin Luck ([@vitch](https://github.com/vitch))
18
+ - Luke Melia ([@lukemelia](https://github.com/lukemelia))
19
+
3
20
  ## [v1.0.1](https://github.com/ember-cli-deploy/ember-cli-deploy-s3-index/tree/v1.0.1)
4
21
  [Full Changelog](https://github.com/ember-cli-deploy/ember-cli-deploy-s3-index/compare/v1.0.0...v1.0.1)
5
22
 
package/README.md CHANGED
@@ -170,6 +170,22 @@ If you are using DigitalOcean spaces you need to set this setting to `false`.
170
170
 
171
171
  *Default:* `true`
172
172
 
173
+ ### didDeployMessage
174
+
175
+ A message that will be displayed after the index file has been successfully uploaded to S3. By default this message will only display if the revision for `revisionData.revisionKey` of the deployment context has been activated.
176
+
177
+ *Default:*
178
+
179
+ ```javascript
180
+ if (context.revisionData.revisionKey && !context.revisionData.activatedRevisionKey) {
181
+ return "Deployed but did not activate revision " + context.revisionData.revisionKey + ". "
182
+ + "To activate, run: "
183
+ + "ember deploy:activate " + context.revisionData.revisionKey + " --environment=" + context.deployEnvironment + "\n";
184
+ }
185
+ ```
186
+
187
+
188
+
173
189
  ### How do I activate a revision?
174
190
 
175
191
  A user can activate a revision by either:
package/RELEASE.md ADDED
@@ -0,0 +1,60 @@
1
+ # Release Process
2
+
3
+ Releases are mostly automated using
4
+ [release-it](https://github.com/release-it/release-it/) and
5
+ [lerna-changelog](https://github.com/lerna/lerna-changelog/).
6
+
7
+ ## Preparation
8
+
9
+ Since the majority of the actual release process is automated, the primary
10
+ remaining task prior to releasing is confirming that all pull requests that
11
+ have been merged since the last release have been labeled with the appropriate
12
+ `lerna-changelog` labels and the titles have been updated to ensure they
13
+ represent something that would make sense to our users. Some great information
14
+ on why this is important can be found at
15
+ [keepachangelog.com](https://keepachangelog.com/en/1.0.0/), but the overall
16
+ guiding principle here is that changelogs are for humans, not machines.
17
+
18
+ When reviewing merged PR's the labels to be used are:
19
+
20
+ * breaking - Used when the PR is considered a breaking change.
21
+ * enhancement - Used when the PR adds a new feature or enhancement.
22
+ * bug - Used when the PR fixes a bug included in a previous release.
23
+ * documentation - Used when the PR adds or updates documentation.
24
+ * internal - Used for internal changes that still require a mention in the
25
+ changelog/release notes.
26
+
27
+ ## Release
28
+
29
+ Once the prep work is completed, the actual release is straight forward:
30
+
31
+ * First, ensure that you have installed your projects dependencies:
32
+
33
+ ```sh
34
+ yarn install
35
+ ```
36
+
37
+ * Second, ensure that you have obtained a
38
+ [GitHub personal access token][generate-token] with the `repo` scope (no
39
+ other permissions are needed). Make sure the token is available as the
40
+ `GITHUB_AUTH` environment variable.
41
+
42
+ For instance:
43
+
44
+ ```bash
45
+ export GITHUB_AUTH=abc123def456
46
+ ```
47
+
48
+ [generate-token]: https://github.com/settings/tokens/new?scopes=repo&description=GITHUB_AUTH+env+variable
49
+
50
+ * And last (but not least 😁) do your release.
51
+
52
+ ```sh
53
+ npx release-it
54
+ ```
55
+
56
+ [release-it](https://github.com/release-it/release-it/) manages the actual
57
+ release process. It will prompt you to to choose the version number after which
58
+ you will have the chance to hand tweak the changelog to be used (for the
59
+ `CHANGELOG.md` and GitHub release), then `release-it` continues on to tagging,
60
+ pushing the tag and commits, etc.
package/index.js CHANGED
@@ -34,6 +34,15 @@ module.exports = {
34
34
  brotliCompressedFiles: function(context) {
35
35
  return context.brotliCompressedFiles || [];
36
36
  },
37
+ didDeployMessage: function(context){
38
+ var revisionKey = context.revisionData && context.revisionData.revisionKey;
39
+ var activatedRevisionKey = context.revisionData && context.revisionData.activatedRevisionKey;
40
+ if (revisionKey && !activatedRevisionKey) {
41
+ return "Deployed but did not activate revision " + revisionKey + ". "
42
+ + "To activate, run: "
43
+ + "ember deploy:activate " + context.deployTarget + " --revision=" + revisionKey + "\n";
44
+ }
45
+ },
37
46
  allowOverwrite: false
38
47
  },
39
48
 
@@ -103,7 +112,22 @@ module.exports = {
103
112
  this.log('preparing to activate `' + revisionKey + '`', { verbose: true });
104
113
 
105
114
  var s3 = new this.S3({ plugin: this });
106
- return s3.activate(options);
115
+ return s3.activate(options).then(() => {
116
+ this.log(`✔ Activated revision \`${revisionKey}\``, {});
117
+
118
+ return {
119
+ revisionData: {
120
+ activatedRevisionKey: revisionKey
121
+ }
122
+ }
123
+ });
124
+ },
125
+
126
+ didDeploy: function(/* context */){
127
+ var didDeployMessage = this.readConfig('didDeployMessage');
128
+ if (didDeployMessage) {
129
+ this.log(didDeployMessage);
130
+ }
107
131
  },
108
132
 
109
133
  fetchRevisions: function(context) {
package/lib/s3.js CHANGED
@@ -62,6 +62,7 @@ module.exports = CoreObject.extend({
62
62
  var isGzipped = gzippedFilePaths.indexOf(options.filePattern) !== -1;
63
63
  var isBrotliCompressed = brotliCompressedFilePaths.indexOf(options.filePattern) !== -1;
64
64
  var serverSideEncryption = options.serverSideEncryption;
65
+ var checkForOverwrite = RSVP.resolve();
65
66
 
66
67
  var params = {
67
68
  Bucket: bucket,
@@ -83,14 +84,17 @@ module.exports = CoreObject.extend({
83
84
  params.ContentEncoding = 'br';
84
85
  }
85
86
 
86
- return this.fetchRevisions(options)
87
- .then(function(revisions) {
88
- var found = revisions.map(function(element) { return element.revision; }).indexOf(options.revisionKey);
89
- if (found >= 0 && !allowOverwrite) {
90
- return RSVP.reject("REVISION ALREADY UPLOADED! (set `allowOverwrite: true` if you want to support overwriting revisions)");
91
- }
92
- return RSVP.resolve();
93
- })
87
+ if (!allowOverwrite) {
88
+ checkForOverwrite = this.findRevision(options)
89
+ .then(function(found) {
90
+ if (found !== undefined) {
91
+ return RSVP.reject("REVISION ALREADY UPLOADED! (set `allowOverwrite: true` if you want to support overwriting revisions)");
92
+ }
93
+ return RSVP.resolve();
94
+ })
95
+ }
96
+
97
+ return checkForOverwrite
94
98
  .then(readFile.bind(this, options.filePath))
95
99
  .then(function(fileContents) {
96
100
  params.Body = fileContents;
@@ -131,9 +135,8 @@ module.exports = CoreObject.extend({
131
135
  params.ServerSideEncryption = serverSideEncryption;
132
136
  }
133
137
 
134
- return this.fetchRevisions(options).then(function(revisions) {
135
- var found = revisions.map(function(element) { return element.revision; }).indexOf(options.revisionKey);
136
- if (found >= 0) {
138
+ return this.findRevision(options).then(function(found) {
139
+ if (found !== undefined) {
137
140
  return copyObject(params).then(function() {
138
141
  plugin.log('✔ ' + revisionKey + " => " + indexKey);
139
142
  });
@@ -143,6 +146,17 @@ module.exports = CoreObject.extend({
143
146
  });
144
147
  },
145
148
 
149
+ findRevision: function(options) {
150
+ var client = this._client;
151
+ var listObjects = RSVP.denodeify(client.listObjects.bind(client));
152
+ var bucket = options.bucket;
153
+ var prefix = options.prefix;
154
+ var revisionPrefix = joinUriSegments(prefix, options.filePattern + ":" + options.revisionKey);
155
+
156
+ return listObjects({ Bucket: bucket, Prefix: revisionPrefix })
157
+ .then((response) => response.Contents.find((element) => element.Key === revisionPrefix));
158
+ },
159
+
146
160
  fetchRevisions: function(options) {
147
161
  var client = this._client;
148
162
  var bucket = options.bucket;
package/package.json CHANGED
@@ -1,7 +1,14 @@
1
1
  {
2
2
  "name": "ember-cli-deploy-s3-index",
3
- "version": "1.3.1",
3
+ "version": "3.0.0",
4
4
  "description": "Ember CLI Deploy plugin to deploy ember-cli's bootstrap index file to S3.",
5
+ "keywords": [
6
+ "ember-addon",
7
+ "ember-cli-deploy-plugin"
8
+ ],
9
+ "repository": "https://github.com/ember-cli-deploy/ember-cli-deploy-s3-index",
10
+ "license": "MIT",
11
+ "author": "",
5
12
  "directories": {
6
13
  "doc": "doc",
7
14
  "test": "tests"
@@ -10,40 +17,42 @@
10
17
  "release": "release-it",
11
18
  "test": "node tests/runner.js && ./node_modules/.bin/eslint index.js lib/* tests/**/*.js"
12
19
  },
13
- "repository": "https://github.com/ember-cli-deploy/ember-cli-deploy-s3-index",
14
- "engines": {
15
- "node": ">= 4"
20
+ "dependencies": {
21
+ "aws-sdk": "^2.667.0",
22
+ "core-object": "^3.0.0",
23
+ "ember-cli-deploy-plugin": "^0.2.9",
24
+ "mime-types": "^2.1.27",
25
+ "rsvp": "^4.8.5"
16
26
  },
17
- "author": "",
18
- "license": "MIT",
19
27
  "devDependencies": {
20
- "github": "^0.2.4",
21
28
  "chai": "^4.2.0",
22
29
  "chai-as-promised": "^7.1.1",
23
30
  "ember-cli": "~3.18.0",
24
31
  "eslint": "^7.0.0",
25
32
  "glob": "^7.1.6",
26
33
  "mocha": "^7.1.2",
27
- "release-it": "*"
34
+ "release-it": "^14.2.1",
35
+ "release-it-lerna-changelog": "^3.1.0"
28
36
  },
29
- "keywords": [
30
- "ember-addon",
31
- "ember-cli-deploy-plugin"
32
- ],
33
- "dependencies": {
34
- "aws-sdk": "^2.667.0",
35
- "core-object": "^3.0.0",
36
- "ember-cli-deploy-plugin": "^0.2.9",
37
- "mime-types": "^2.1.27",
38
- "rsvp": "^4.8.5"
37
+ "engines": {
38
+ "node": "14.* || 16.* || 18.* || >= 20"
39
+ },
40
+ "publishConfig": {
41
+ "registry": "https://registry.npmjs.org"
39
42
  },
40
43
  "release-it": {
41
44
  "git": {
42
- "changelog": "./bin/changelog",
43
45
  "requireCleanWorkingDir": false
44
46
  },
45
47
  "github": {
46
- "release": true
48
+ "release": true,
49
+ "tokenRef": "GITHUB_AUTH"
50
+ },
51
+ "plugins": {
52
+ "release-it-lerna-changelog": {
53
+ "infile": "CHANGELOG.md",
54
+ "launchEditor": true
55
+ }
47
56
  }
48
57
  }
49
58
  }
package/bin/changelog DELETED
@@ -1,84 +0,0 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
-
4
- /*
5
- * This script generates the template a changelog by comparing a current version
6
- * with master. Run this, copy what's logged into the `CHANGELOG.md` and update
7
- * the top section based on the changes listed in "Community Contributions"
8
- *
9
- * Usage:
10
- *
11
- * bin/changelog
12
- */
13
-
14
- var EOL = require('os').EOL;
15
- var RSVP = require('rsvp');
16
- var GitHubApi = require('github');
17
-
18
- var github = new GitHubApi({version: '3.0.0'});
19
- var compareCommits = RSVP.denodeify(github.repos.compareCommits);
20
- var currentVersion = 'v' + require('../package').version;
21
-
22
- var user = 'ember-cli-deploy';
23
-
24
- var repo = 'ember-cli-deploy-s3-index';
25
- compareCommits({
26
- user: user,
27
- repo: repo,
28
- base: currentVersion,
29
- head: 'master'
30
- }).then(function(res) {
31
- return res.commits.map(function(commitInfo) {
32
- return commitInfo.commit.message
33
-
34
- }).filter(function(message) {
35
- return message.indexOf('Merge pull request #') > -1;
36
-
37
- }).map(function(message) {
38
- var numAndAuthor = message.match(/#(\d+) from (.*)\//).slice(1,3);
39
- var title = message.split('\n\n')[1];
40
-
41
- return {
42
- number: +numAndAuthor[0],
43
- author: numAndAuthor[1],
44
- title: title
45
- };
46
-
47
- }).sort(function(a, b) {
48
- return a.number > b.number;
49
- }).map(function(pr) {
50
- var link = '[#' + pr.number + ']' +
51
- '(https://github.com/' + user + '/' + repo + '/pull/' + pr.number + ')';
52
- var title = pr.title;
53
- var author = '[@' + pr.author + ']' +
54
- '(https://github.com/' + pr.author +')';
55
-
56
- return '- ' + link + ' ' + title + ' ' + author;
57
-
58
- }).join('\n');
59
-
60
- }).then(function(contributions) {
61
- var changelog = generateChangelog(contributions);
62
-
63
- console.log(changelog);
64
- }).catch(function(err) {
65
- console.error(err);
66
- })
67
-
68
- function generateChangelog(contributions) {
69
- var header = `
70
- The following changes are required if you are upgrading from the previous
71
- version:
72
- - Users
73
- + Upgrade your project's ember-cli version - [docs](http://www.ember-cli.com/#project-update)
74
- - Addon Developers
75
- + No changes required
76
- - Core Contributors
77
- + No changes required
78
- #### Community Contributions
79
- `;
80
-
81
- var footer = 'Thank you to all who took the time to contribute!';
82
-
83
- return header + EOL + EOL + contributions + EOL + EOL + footer;
84
- }