Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.

Commit 4d9547c

Browse files
renovate[bot]markdalgleish
authored andcommitted
fix(deps): Update html-sketchapp to v3.x (#38)
The `install` command now downloads the Sketch plugin from html-sketchapp's GitHub releases, since it's no longer published to npm.
1 parent 3fa225e commit 4d9547c

File tree

12 files changed

+55
-34
lines changed

12 files changed

+55
-34
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
node_modules/
22
dist/
3+
.tmp/
34

45
package-lock.json
56
yarn.lock

bin/cli.js

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@ const getPort = require('get-port');
77
const serve = require('serve');
88
const puppeteer = require('puppeteer');
99
const { rollup } = require('rollup');
10-
const waitOn = promisify(require('wait-on'));
11-
const mkdirp = promisify(require('mkdirp'));
12-
const fs = require('fs');
10+
const waitOnAsync = promisify(require('wait-on'));
11+
const mkdirpAsync = promisify(require('mkdirp'));
12+
const writeFileAsync = promisify(require('fs').writeFile);
1313
const path = require('path');
1414

15-
const writeFileAsync = promisify(fs.writeFile);
16-
1715
const configPath = findUp.sync(['html-sketchapp.config.js']);
1816
const config = configPath ? require(configPath) : {};
1917

@@ -70,7 +68,7 @@ require('yargs')
7068
const symbolsUrl = argv.serve ? urlJoin(`http://localhost:${String(port)}`, argv.url || '/') : url;
7169
const debug = argv.debug;
7270

73-
await waitOn({
71+
await waitOnAsync({
7472
timeout: 5000,
7573
headers: { accept: 'text/html' },
7674
// Force 'wait-on' to make a GET request rather than a HEAD request
@@ -132,7 +130,7 @@ require('yargs')
132130
const asketchPageJSON = await page.evaluate('generateAlmostSketch.getPageJSON()');
133131

134132
const outputPath = path.resolve(process.cwd(), argv.outDir);
135-
await mkdirp(outputPath);
133+
await mkdirpAsync(outputPath);
136134

137135
const outputPagePath = path.join(outputPath, 'page.asketch.json');
138136
const outputDocumentPath = path.join(outputPath, 'document.asketch.json');
@@ -156,10 +154,26 @@ require('yargs')
156154
process.exit(1);
157155
}
158156
})
159-
.command('install', 'Install the html-sketchapp Sketch plugin', {}, () => {
160-
const htmlSketchappPath = path.dirname(require.resolve('@brainly/html-sketchapp/package.json'));
161-
const pluginPath = path.resolve(htmlSketchappPath, 'asketch2sketch.sketchplugin');
162-
157+
.command('install', 'Install the html-sketchapp Sketch plugin', {}, async () => {
158+
const { version } = require('@brainly/html-sketchapp/package.json');
159+
console.log(`Detected html-sketchapp v${version}`);
160+
161+
const tmpDirPath = path.resolve(__dirname, '../', '.tmp');
162+
const rimrafAsync = promisify(require('rimraf'));
163+
await rimrafAsync(tmpDirPath);
164+
await mkdirpAsync(tmpDirPath);
165+
166+
const releaseUrl = `http://github.com/brainly/html-sketchapp/releases/download/v${version}/asketch2sketch.sketchplugin.zip`;
167+
console.log(`Downloading from ${releaseUrl}`);
168+
const axios = require('axios');
169+
const { data } = await axios(releaseUrl, { responseType: 'arraybuffer' });
170+
171+
console.log(`Extracting to ${tmpDirPath}`);
172+
const decompress = require('decompress');
173+
await decompress(data, tmpDirPath);
174+
175+
const pluginPath = path.resolve(tmpDirPath, 'asketch2sketch.sketchplugin');
176+
console.log(`Installing from ${pluginPath}`);
163177
const opn = require('opn');
164178
opn(pluginPath, { wait: false });
165179
})

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,16 @@
3333
},
3434
"homepage": "https://github.com/seek-oss/html-sketchapp-cli#readme",
3535
"dependencies": {
36-
"@brainly/html-sketchapp": "^2.0.0",
36+
"@brainly/html-sketchapp": "^3.0.0",
37+
"axios": "^0.18.0",
38+
"decompress": "^4.2.0",
3739
"es6-promisify": "^6.0.0",
3840
"find-up": "^2.1.0",
3941
"get-port": "^3.2.0",
4042
"mkdirp": "^0.5.1",
4143
"opn": "^5.1.0",
4244
"puppeteer": "^1.0.0",
45+
"rimraf": "^2.6.2",
4346
"rollup": "^0.57.1",
4447
"rollup-plugin-commonjs": "^9.1.0",
4548
"rollup-plugin-node-resolve": "^3.3.0",
@@ -58,7 +61,6 @@
5861
"eslint-config-seek": "^3.0.0",
5962
"husky": "^0.14.3",
6063
"jest": "^22.0.1",
61-
"rimraf": "^2.6.2",
6264
"semantic-release": "^15.1.3",
6365
"traverse": "^0.6.6",
6466
"travis-deploy-once": "^4.3.4"

script/generateAlmostSketch.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
import Page from '@brainly/html-sketchapp/html2asketch/page.js';
2-
import Document from '@brainly/html-sketchapp/html2asketch/document.js';
3-
import Text from '@brainly/html-sketchapp/html2asketch/text.js';
4-
import nodeToSketchLayers from '@brainly/html-sketchapp/html2asketch/nodeToSketchLayers.js';
5-
import SymbolMaster from '@brainly/html-sketchapp/html2asketch/symbolMaster.js';
1+
import htmlSketchapp from '@brainly/html-sketchapp'
2+
3+
const {
4+
Page,
5+
Document,
6+
Text,
7+
nodeToSketchLayers,
8+
SymbolMaster
9+
} = htmlSketchapp;
610

711
const getAllLayers = (item, symbolMastersByName = {}) => {
812
const itemAndChildren = [item, ...item.querySelectorAll('*')];

test/config-file-path/__snapshots__/file.test.js.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ Object {
105105
"frame": Object {
106106
"_class": "rect",
107107
"constrainProportions": false,
108-
"height": 784,
109-
"width": 352,
108+
"height": 352,
109+
"width": 784,
110110
"x": 0,
111111
"y": 0,
112112
},

test/config-file/__snapshots__/file.test.js.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ Object {
105105
"frame": Object {
106106
"_class": "rect",
107107
"constrainProportions": false,
108-
"height": 784,
109-
"width": 352,
108+
"height": 352,
109+
"width": 784,
110110
"x": 0,
111111
"y": 0,
112112
},

test/file/__snapshots__/file.test.js.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ Object {
105105
"frame": Object {
106106
"_class": "rect",
107107
"constrainProportions": false,
108-
"height": 784,
109-
"width": 352,
108+
"height": 352,
109+
"width": 784,
110110
"x": 0,
111111
"y": 0,
112112
},

test/nested-symbols/__snapshots__/nested-symbols.test.js.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ Object {
4040
"frame": Object {
4141
"_class": "rect",
4242
"constrainProportions": false,
43-
"height": 784,
44-
"width": 72,
43+
"height": 72,
44+
"width": 784,
4545
"x": 0,
4646
"y": 0,
4747
},

test/serve-with-url/__snapshots__/serve-with-url.test.js.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ Object {
105105
"frame": Object {
106106
"_class": "rect",
107107
"constrainProportions": false,
108-
"height": 784,
109-
"width": 352,
108+
"height": 352,
109+
"width": 784,
110110
"x": 0,
111111
"y": 0,
112112
},

test/serve/__snapshots__/serve.test.js.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ Object {
105105
"frame": Object {
106106
"_class": "rect",
107107
"constrainProportions": false,
108-
"height": 784,
109-
"width": 352,
108+
"height": 352,
109+
"width": 784,
110110
"x": 0,
111111
"y": 0,
112112
},

0 commit comments

Comments
 (0)