create-instantsearch-app 6.4.0 → 6.4.2
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/package.json +2 -2
- package/src/api/__tests__/index.test.js +1 -0
- package/src/api/__tests__/resolve-template.test.js +1 -0
- package/src/api/check-config.js +2 -1
- package/src/api/index.js +4 -2
- package/src/api/resolve-template.js +2 -0
- package/src/cli/__tests__/getConfiguration.test.js +1 -0
- package/src/cli/__tests__/getInformationFromIndex.js +1 -0
- package/src/cli/__tests__/postProcessAnswers.js +1 -1
- package/src/cli/getInformationFromIndex.js +1 -1
- package/src/cli/index.js +7 -5
- package/src/tasks/common/build.js +2 -2
- package/src/tasks/common/clean.js +1 -0
- package/src/tasks/ios/install.js +1 -0
- package/src/tasks/ios/setup.js +1 -0
- package/src/tasks/node/install.js +3 -1
- package/src/tasks/node/teardown.js +3 -1
- package/src/utils/__tests__/fetchLibraryVersions.test.js +24 -0
- package/src/utils/fetchLibraryVersions.js +37 -0
- package/src/utils/index.js +3 -19
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-instantsearch-app",
|
|
3
|
-
"version": "6.4.
|
|
3
|
+
"version": "6.4.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "⚡️ Build InstantSearch apps at the speed of thought",
|
|
6
6
|
"keywords": [
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"jest-image-snapshot": "2.12.0",
|
|
53
53
|
"walk-sync": "2.0.2"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "c0a9fe132d2c64939763f64f7c265ed8ceb89ae2"
|
|
56
56
|
}
|
package/src/api/check-config.js
CHANGED
package/src/api/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
|
|
3
|
-
const resolveTemplate = require('./resolve-template');
|
|
2
|
+
|
|
4
3
|
const buildTask = require('../tasks/common/build');
|
|
5
4
|
const cleanTask = require('../tasks/common/clean');
|
|
6
5
|
const { getAllTemplates } = require('../utils');
|
|
7
6
|
|
|
7
|
+
const checkConfig = require('./check-config');
|
|
8
|
+
const resolveTemplate = require('./resolve-template');
|
|
9
|
+
|
|
8
10
|
const supportedTemplates = getAllTemplates();
|
|
9
11
|
|
|
10
12
|
function noop() {}
|
package/src/cli/index.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
const os = require('os');
|
|
2
3
|
const path = require('path');
|
|
3
4
|
const process = require('process');
|
|
4
|
-
|
|
5
|
+
|
|
6
|
+
const chalk = require('chalk');
|
|
5
7
|
const program = require('commander');
|
|
6
8
|
const inquirer = require('inquirer');
|
|
7
|
-
const chalk = require('chalk');
|
|
8
9
|
const semver = require('semver');
|
|
9
10
|
|
|
11
|
+
const { version } = require('../../package.json');
|
|
10
12
|
const createInstantSearchApp = require('../api');
|
|
11
13
|
const {
|
|
12
14
|
checkAppPath,
|
|
@@ -17,13 +19,13 @@ const {
|
|
|
17
19
|
getTemplatePath,
|
|
18
20
|
splitArray,
|
|
19
21
|
} = require('../utils');
|
|
22
|
+
|
|
23
|
+
const getAnswersDefaultValues = require('./getAnswersDefaultValues');
|
|
20
24
|
const getAttributesFromIndex = require('./getAttributesFromIndex');
|
|
25
|
+
const getConfiguration = require('./getConfiguration');
|
|
21
26
|
const getFacetsFromIndex = require('./getFacetsFromIndex');
|
|
22
|
-
const getAnswersDefaultValues = require('./getAnswersDefaultValues');
|
|
23
27
|
const isQuestionAsked = require('./isQuestionAsked');
|
|
24
|
-
const getConfiguration = require('./getConfiguration');
|
|
25
28
|
const postProcessAnswers = require('./postProcessAnswers');
|
|
26
|
-
const { version } = require('../../package.json');
|
|
27
29
|
|
|
28
30
|
let appPathFromArgument;
|
|
29
31
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const metalsmith = require('metalsmith');
|
|
2
1
|
const inPlace = require('@metalsmith/in-place');
|
|
3
|
-
const rename = require('metalsmith-rename');
|
|
4
2
|
const remove = require('@metalsmith/remove');
|
|
3
|
+
const metalsmith = require('metalsmith');
|
|
4
|
+
const rename = require('metalsmith-rename');
|
|
5
5
|
|
|
6
6
|
module.exports = function build(config) {
|
|
7
7
|
return new Promise((resolve, reject) => {
|
package/src/tasks/ios/install.js
CHANGED
package/src/tasks/ios/setup.js
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const https = require('https');
|
|
2
|
+
|
|
3
|
+
const { fetchLibraryVersions } = require('../fetchLibraryVersions');
|
|
4
|
+
|
|
5
|
+
describe('fetchLibraryVersions', () => {
|
|
6
|
+
test('return versions for a library', async () => {
|
|
7
|
+
expect(await fetchLibraryVersions('react-instantsearch')).toEqual(
|
|
8
|
+
expect.arrayContaining([expect.any(String)])
|
|
9
|
+
);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test('return versions from cache if available', async () => {
|
|
13
|
+
const httpsSpy = jest.spyOn(https, 'get');
|
|
14
|
+
|
|
15
|
+
await fetchLibraryVersions('react-instantsearch-core');
|
|
16
|
+
expect(httpsSpy).toHaveBeenCalledTimes(1);
|
|
17
|
+
|
|
18
|
+
await fetchLibraryVersions('react-instantsearch-core');
|
|
19
|
+
expect(httpsSpy).toHaveBeenCalledTimes(1);
|
|
20
|
+
|
|
21
|
+
await fetchLibraryVersions('instantsearch.js');
|
|
22
|
+
expect(httpsSpy).toHaveBeenCalledTimes(2);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const https = require('https');
|
|
2
|
+
|
|
3
|
+
function fetchCachedLibraryVersions() {
|
|
4
|
+
const cache = new Map();
|
|
5
|
+
return function fetchLibraryVersions(libraryName) {
|
|
6
|
+
if (cache.has(libraryName)) {
|
|
7
|
+
return Promise.resolve(cache.get(libraryName));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return new Promise((resolve, reject) => {
|
|
11
|
+
https
|
|
12
|
+
.get(`https://registry.npmjs.org/${libraryName}`, (res) => {
|
|
13
|
+
let body = '';
|
|
14
|
+
res.on('data', (chunk) => {
|
|
15
|
+
body += chunk;
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
res.on('end', () => {
|
|
19
|
+
try {
|
|
20
|
+
const library = JSON.parse(body);
|
|
21
|
+
const versions = Object.keys(library.versions).reverse();
|
|
22
|
+
|
|
23
|
+
cache.set(libraryName, versions);
|
|
24
|
+
resolve(versions);
|
|
25
|
+
} catch (err) {
|
|
26
|
+
reject(err);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
})
|
|
30
|
+
.on('error', reject);
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
module.exports = {
|
|
36
|
+
fetchLibraryVersions: fetchCachedLibraryVersions(),
|
|
37
|
+
};
|
package/src/utils/index.js
CHANGED
|
@@ -1,22 +1,14 @@
|
|
|
1
|
+
const { execSync } = require('child_process');
|
|
1
2
|
const fs = require('fs');
|
|
2
3
|
const path = require('path');
|
|
3
|
-
|
|
4
|
+
|
|
4
5
|
const chalk = require('chalk');
|
|
5
6
|
const semver = require('semver');
|
|
6
7
|
const validateProjectName = require('validate-npm-package-name');
|
|
7
|
-
const algoliasearch = require('algoliasearch');
|
|
8
8
|
|
|
9
|
+
const { fetchLibraryVersions } = require('./fetchLibraryVersions');
|
|
9
10
|
const TEMPLATES_FOLDER = path.join(__dirname, '../templates');
|
|
10
11
|
|
|
11
|
-
const algoliaConfig = {
|
|
12
|
-
appId: 'OFCNCOG2CU',
|
|
13
|
-
apiKey: 'f54e21fa3a2a0160595bb058179bfb1e',
|
|
14
|
-
indexName: 'npm-search',
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const client = algoliasearch(algoliaConfig.appId, algoliaConfig.apiKey);
|
|
18
|
-
const index = client.initIndex(algoliaConfig.indexName);
|
|
19
|
-
|
|
20
12
|
function checkAppName(appName) {
|
|
21
13
|
const validationResult = validateProjectName(appName);
|
|
22
14
|
|
|
@@ -129,14 +121,6 @@ function getTemplatePath(templateName) {
|
|
|
129
121
|
return templateName;
|
|
130
122
|
}
|
|
131
123
|
|
|
132
|
-
async function fetchLibraryVersions(libraryName) {
|
|
133
|
-
const library = await index.getObject(libraryName, {
|
|
134
|
-
attributesToRetrieve: ['versions'],
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
return Object.keys(library.versions).reverse();
|
|
138
|
-
}
|
|
139
|
-
|
|
140
124
|
function getLibraryVersion({ libraryName, supportedVersion = '' }) {
|
|
141
125
|
return async (getVersion) => {
|
|
142
126
|
const versions = await fetchLibraryVersions(libraryName);
|