create-instantsearch-app 6.4.1 → 7.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.
- package/README.md +4 -5
- package/package.json +3 -2
- package/src/api/__tests__/__snapshots__/index.test.js.snap +4 -4
- package/src/api/__tests__/resolve-template.test.js +0 -28
- package/src/api/resolve-template.js +1 -28
- package/src/templates/React InstantSearch/.editorconfig +0 -1
- package/src/templates/React InstantSearch/.gitignore.template +20 -18
- package/src/templates/React InstantSearch/.template.js +4 -3
- package/src/templates/React InstantSearch/README.md +0 -2
- package/src/templates/React InstantSearch/package.json +8 -21
- package/src/templates/React InstantSearch/src/App.css +11 -0
- package/src/templates/{React InstantSearch Hooks → React InstantSearch}/src/App.tsx.hbs +3 -3
- package/src/templates/React InstantSearch Native/.gitignore.template +13 -16
- package/src/templates/React InstantSearch Native/.template.js +2 -1
- package/src/templates/{React InstantSearch Hooks Native → React InstantSearch Native}/App.tsx.hbs +1 -1
- package/src/templates/React InstantSearch Native/app.json +24 -1
- package/src/templates/React InstantSearch Native/package.json +14 -16
- package/src/templates/{React InstantSearch Hooks Native → React InstantSearch Native}/src/InfiniteHits.tsx +1 -1
- package/src/templates/{React InstantSearch Hooks Native → React InstantSearch Native}/src/SearchBox.tsx.hbs +1 -1
- package/src/utils/__tests__/fetchLibraryVersions.test.js +24 -0
- package/src/utils/__tests__/index.test.js +8 -5
- package/src/utils/fetchLibraryVersions.js +37 -0
- package/src/utils/index.js +1 -18
- package/src/templates/Autocomplete.js 0/.editorconfig +0 -9
- package/src/templates/Autocomplete.js 0/.eslintignore +0 -3
- package/src/templates/Autocomplete.js 0/.eslintrc.js +0 -3
- package/src/templates/Autocomplete.js 0/.gitignore.template +0 -22
- package/src/templates/Autocomplete.js 0/.prettierrc +0 -5
- package/src/templates/Autocomplete.js 0/.template.js +0 -13
- package/src/templates/Autocomplete.js 0/README.md +0 -21
- package/src/templates/Autocomplete.js 0/favicon.png +0 -0
- package/src/templates/Autocomplete.js 0/index.html.hbs +0 -46
- package/src/templates/Autocomplete.js 0/manifest.webmanifest +0 -15
- package/src/templates/Autocomplete.js 0/package.json +0 -26
- package/src/templates/Autocomplete.js 0/src/app.css +0 -85
- package/src/templates/Autocomplete.js 0/src/app.js.hbs +0 -31
- package/src/templates/Autocomplete.js 0/src/index.css +0 -7
- package/src/templates/InstantSearch.js 2/.editorconfig +0 -9
- package/src/templates/InstantSearch.js 2/.eslintignore +0 -3
- package/src/templates/InstantSearch.js 2/.eslintrc.js +0 -3
- package/src/templates/InstantSearch.js 2/.gitignore.template +0 -22
- package/src/templates/InstantSearch.js 2/.prettierrc +0 -5
- package/src/templates/InstantSearch.js 2/.template.js +0 -14
- package/src/templates/InstantSearch.js 2/README.md +0 -21
- package/src/templates/InstantSearch.js 2/favicon.png +0 -0
- package/src/templates/InstantSearch.js 2/index.html.hbs +0 -56
- package/src/templates/InstantSearch.js 2/manifest.webmanifest +0 -15
- package/src/templates/InstantSearch.js 2/package.json +0 -22
- package/src/templates/InstantSearch.js 2/src/app.css +0 -75
- package/src/templates/InstantSearch.js 2/src/app.js.hbs +0 -54
- package/src/templates/InstantSearch.js 2/src/index.css +0 -10
- package/src/templates/JavaScript Helper 2/.editorconfig +0 -9
- package/src/templates/JavaScript Helper 2/.eslintignore +0 -3
- package/src/templates/JavaScript Helper 2/.eslintrc.js +0 -3
- package/src/templates/JavaScript Helper 2/.gitignore.template +0 -22
- package/src/templates/JavaScript Helper 2/.prettierrc +0 -5
- package/src/templates/JavaScript Helper 2/.template.js +0 -14
- package/src/templates/JavaScript Helper 2/README.md +0 -21
- package/src/templates/JavaScript Helper 2/favicon.png +0 -0
- package/src/templates/JavaScript Helper 2/index.html.hbs +0 -42
- package/src/templates/JavaScript Helper 2/manifest.webmanifest +0 -15
- package/src/templates/JavaScript Helper 2/package.json +0 -26
- package/src/templates/JavaScript Helper 2/src/app.css +0 -74
- package/src/templates/JavaScript Helper 2/src/app.js.hbs +0 -44
- package/src/templates/JavaScript Helper 2/src/index.css +0 -10
- package/src/templates/React InstantSearch/.eslintrc.js +0 -3
- package/src/templates/React InstantSearch/public/favicon.png +0 -0
- package/src/templates/React InstantSearch/public/index.html +0 -29
- package/src/templates/React InstantSearch/public/manifest.json +0 -15
- package/src/templates/React InstantSearch/src/App.js.hbs +0 -112
- package/src/templates/React InstantSearch/src/index.css +0 -10
- package/src/templates/React InstantSearch/src/index.js +0 -6
- package/src/templates/React InstantSearch Hooks/.editorconfig +0 -8
- package/src/templates/React InstantSearch Hooks/.gitignore.template +0 -23
- package/src/templates/React InstantSearch Hooks/.prettierrc +0 -5
- package/src/templates/React InstantSearch Hooks/.template.js +0 -25
- package/src/templates/React InstantSearch Hooks/README.md +0 -19
- package/src/templates/React InstantSearch Hooks/package.json +0 -21
- package/src/templates/React InstantSearch Hooks/src/App.css +0 -71
- package/src/templates/React InstantSearch Hooks Native/.gitignore.template +0 -14
- package/src/templates/React InstantSearch Hooks Native/.template.js +0 -34
- package/src/templates/React InstantSearch Hooks Native/README.md +0 -19
- package/src/templates/React InstantSearch Hooks Native/app.json +0 -30
- package/src/templates/React InstantSearch Hooks Native/babel.config.js +0 -6
- package/src/templates/React InstantSearch Hooks Native/package.json +0 -30
- package/src/templates/React InstantSearch Native/.editorconfig +0 -9
- package/src/templates/React InstantSearch Native/.eslintrc.js +0 -3
- package/src/templates/React InstantSearch Native/.prettierrc +0 -5
- package/src/templates/React InstantSearch Native/.watchmanconfig +0 -1
- package/src/templates/React InstantSearch Native/App.js.hbs +0 -38
- package/src/templates/React InstantSearch Native/src/Highlight.js +0 -36
- package/src/templates/React InstantSearch Native/src/InfiniteHits.js.hbs +0 -56
- package/src/templates/React InstantSearch Native/src/SearchBox.js.hbs +0 -42
- package/src/templates/React InstantSearch widget/.eslintignore +0 -2
- package/src/templates/React InstantSearch widget/.eslintrc.cjs +0 -13
- package/src/templates/React InstantSearch widget/.prettierrc +0 -5
- package/src/templates/React InstantSearch widget/.template.js +0 -21
- package/src/templates/React InstantSearch widget/CONTRIBUTING.md +0 -49
- package/src/templates/React InstantSearch widget/LICENSE.md.hbs +0 -21
- package/src/templates/React InstantSearch widget/README.md +0 -85
- package/src/templates/React InstantSearch widget/babel.config.cjs +0 -8
- package/src/templates/React InstantSearch widget/example/index.html.hbs +0 -12
- package/src/templates/React InstantSearch widget/example/index.tsx.hbs +0 -22
- package/src/templates/React InstantSearch widget/package.json.hbs +0 -81
- package/src/templates/React InstantSearch widget/src/index.tsx.hbs +0 -3
- package/src/templates/React InstantSearch widget/src/lib/__tests__/dummy-test.tsx.hbs +0 -39
- package/src/templates/React InstantSearch widget/src/lib/component.tsx.hbs +0 -15
- package/src/templates/React InstantSearch widget/src/lib/connector.ts.hbs +0 -35
- package/src/templates/React InstantSearch widget/src/lib/widget.tsx.hbs +0 -14
- package/src/templates/React InstantSearch widget/src/types/connector.ts +0 -17
- package/src/templates/React InstantSearch widget/tsconfig.declaration.json +0 -10
- package/src/templates/React InstantSearch widget/tsconfig.json +0 -20
- package/src/templates/React InstantSearch widget/vite.config.ts +0 -34
- package/src/templates/Vue InstantSearch 1/.editorconfig +0 -9
- package/src/templates/Vue InstantSearch 1/.eslintrc.js +0 -9
- package/src/templates/Vue InstantSearch 1/.gitignore.template +0 -21
- package/src/templates/Vue InstantSearch 1/.prettierrc +0 -5
- package/src/templates/Vue InstantSearch 1/.template.js +0 -14
- package/src/templates/Vue InstantSearch 1/README.md +0 -21
- package/src/templates/Vue InstantSearch 1/babel.config.js +0 -3
- package/src/templates/Vue InstantSearch 1/package.json +0 -35
- package/src/templates/Vue InstantSearch 1/public/favicon.png +0 -0
- package/src/templates/Vue InstantSearch 1/public/index.html +0 -22
- package/src/templates/Vue InstantSearch 1/src/App.vue +0 -167
- package/src/templates/Vue InstantSearch 1/src/main.js +0 -11
- package/src/templates/Vue InstantSearch 2/.editorconfig +0 -9
- package/src/templates/Vue InstantSearch 2/.eslintrc.js +0 -9
- package/src/templates/Vue InstantSearch 2/.gitignore.template +0 -21
- package/src/templates/Vue InstantSearch 2/.prettierrc +0 -5
- package/src/templates/Vue InstantSearch 2/.template.js +0 -15
- package/src/templates/Vue InstantSearch 2/README.md +0 -21
- package/src/templates/Vue InstantSearch 2/babel.config.js +0 -3
- package/src/templates/Vue InstantSearch 2/package.json +0 -37
- package/src/templates/Vue InstantSearch 2/public/favicon.png +0 -0
- package/src/templates/Vue InstantSearch 2/public/index.html +0 -22
- package/src/templates/Vue InstantSearch 2/src/App.vue +0 -147
- package/src/templates/Vue InstantSearch 2/src/main.js +0 -11
- package/src/utils/__tests__/__snapshots__/index.test.js.snap +0 -7
- /package/src/templates/{React InstantSearch Hooks → React InstantSearch}/favicon.png +0 -0
- /package/src/templates/{React InstantSearch Hooks → React InstantSearch}/index.html +0 -0
- /package/src/templates/{React InstantSearch Hooks → React InstantSearch}/src/Panel.tsx +0 -0
- /package/src/templates/{React InstantSearch Hooks → React InstantSearch}/src/index.tsx +0 -0
- /package/src/templates/{React InstantSearch Hooks Native → React InstantSearch Native}/.expo-shared/assets.json +0 -0
- /package/src/templates/{React InstantSearch Hooks Native → React InstantSearch Native}/assets/adaptive-icon.png +0 -0
- /package/src/templates/{React InstantSearch Hooks Native → React InstantSearch Native}/assets/favicon.png +0 -0
- /package/src/templates/{React InstantSearch Hooks Native → React InstantSearch Native}/assets/icon.png +0 -0
- /package/src/templates/{React InstantSearch Hooks Native → React InstantSearch Native}/assets/splash.png +0 -0
- /package/src/templates/{React InstantSearch Hooks Native → React InstantSearch Native}/src/Highlight.tsx +0 -0
- /package/src/templates/{React InstantSearch Hooks Native → React InstantSearch Native}/tsconfig.json +0 -0
- /package/src/templates/{React InstantSearch Hooks Native → React InstantSearch Native}/types/ProductHit.ts +0 -0
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
[![Version][version-svg]][package-url] [![License][license-image]][license-url] [![Build Status][ci-svg]][ci-url]
|
|
6
6
|
|
|
7
|
-
`create-instantsearch-app` is a command line utility that helps you quick start your InstantSearch app using any [Algolia][algolia-website] InstantSearch flavor ([InstantSearch.js][instantsearchjs-github], [React InstantSearch
|
|
7
|
+
`create-instantsearch-app` is a command line utility that helps you quick start your InstantSearch app using any [Algolia][algolia-website] InstantSearch flavor ([InstantSearch.js][instantsearchjs-github], [React InstantSearch][react-instantsearch-github], [Vue InstantSearch][vue-instantsearch-github], [Angular InstantSearch][angular-instantsearch-github], [InstantSearch iOS][instantsearch-ios-github] and [InstantSearch Android][instantsearch-android-github]).
|
|
8
8
|
|
|
9
9
|
<p align="center">
|
|
10
10
|
<img src="preview.png" width="800" alt="Preview">
|
|
@@ -147,9 +147,8 @@ app.create().then(() => console.log('App generated!'));
|
|
|
147
147
|
|
|
148
148
|
You can use the web templates on CodeSandbox:
|
|
149
149
|
|
|
150
|
-
- [InstantSearch.js
|
|
151
|
-
- [InstantSearch
|
|
152
|
-
- [React InstantSearch Hooks](https://codesandbox.io/s/github/algolia/instantsearch/tree/templates/react-instantsearch-hooks)
|
|
150
|
+
- [InstantSearch.js](https://codesandbox.io/s/github/algolia/instantsearch/tree/templates/instantsearch.js)
|
|
151
|
+
- [React InstantSearch](https://codesandbox.io/s/github/algolia/instantsearch/tree/templates/react-instantsearch)
|
|
153
152
|
- [Vue InstantSearch](https://codesandbox.io/s/github/algolia/instantsearch/tree/templates/vue-instantsearch)
|
|
154
153
|
- [Angular InstantSearch](https://codesandbox.io/s/github/algolia/instantsearch/tree/templates/angular-instantsearch)
|
|
155
154
|
- [Autocomplete.js](https://codesandbox.io/s/github/algolia/instantsearch/tree/templates/autocomplete.js)
|
|
@@ -189,7 +188,7 @@ Create InstantSearch App is [MIT licensed](LICENSE).
|
|
|
189
188
|
|
|
190
189
|
[algolia-website]: https://www.algolia.com/?utm_medium=social-owned&utm_source=GitHub&utm_campaign=create-instantsearch-app%20repository
|
|
191
190
|
[instantsearchjs-github]: https://github.com/algolia/instantsearch/tree/master/packages/instantsearch.js
|
|
192
|
-
[react-instantsearch-
|
|
191
|
+
[react-instantsearch-github]: https://github.com/algolia/instantsearch/tree/master/packages/react-instantsearch
|
|
193
192
|
[vue-instantsearch-github]: https://github.com/algolia/instantsearch/tree/master/packages/vue-instantsearch
|
|
194
193
|
[angular-instantsearch-github]: https://github.com/algolia/angular-instantsearch
|
|
195
194
|
[instantsearch-ios-github]: https://github.com/algolia/instantsearch-ios
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-instantsearch-app",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "⚡️ Build InstantSearch apps at the speed of thought",
|
|
6
6
|
"keywords": [
|
|
@@ -49,8 +49,9 @@
|
|
|
49
49
|
"validate-npm-package-name": "3.0.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
+
"@instantsearch/testutils": "1.12.0",
|
|
52
53
|
"jest-image-snapshot": "2.12.0",
|
|
53
54
|
"walk-sync": "2.0.2"
|
|
54
55
|
},
|
|
55
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "94deb1ad0715410c61f4aa285a78a36ccf367fd7"
|
|
56
57
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`Options with invalid name throws 1`] = `
|
|
4
|
-
"Could not create a project called \\"
|
|
4
|
+
"Could not create a project called \\"<red>./WrongNpmName</color>\\" because of npm naming restrictions.
|
|
5
5
|
- name cannot start with a period
|
|
6
6
|
- name can only contain URL-friendly characters"
|
|
7
7
|
`;
|
|
8
8
|
|
|
9
|
-
exports[`Options with unknown template throws 1`] = `"The template directory must contain a configuration file \`.template.js\` or must be one of those: Angular InstantSearch, Autocomplete,
|
|
9
|
+
exports[`Options with unknown template throws 1`] = `"The template directory must contain a configuration file \`.template.js\` or must be one of those: Angular InstantSearch, Autocomplete, InstantSearch Android, InstantSearch iOS, InstantSearch.js, InstantSearch.js widget, JavaScript Client, JavaScript Helper, React InstantSearch, React InstantSearch Native, Vue InstantSearch, Vue InstantSearch with Vue 3"`;
|
|
10
10
|
|
|
11
|
-
exports[`Options with wrong template path throws 1`] = `"The template directory must contain a configuration file \`.template.js\` or must be one of those: Angular InstantSearch, Autocomplete,
|
|
11
|
+
exports[`Options with wrong template path throws 1`] = `"The template directory must contain a configuration file \`.template.js\` or must be one of those: Angular InstantSearch, Autocomplete, InstantSearch Android, InstantSearch iOS, InstantSearch.js, InstantSearch.js widget, JavaScript Client, JavaScript Helper, React InstantSearch, React InstantSearch Native, Vue InstantSearch, Vue InstantSearch with Vue 3"`;
|
|
12
12
|
|
|
13
13
|
exports[`Options without path throws 1`] = `"The option \`path\` is required."`;
|
|
14
14
|
|
|
15
|
-
exports[`Options without template throws 1`] = `"The template directory must contain a configuration file \`.template.js\` or must be one of those: Angular InstantSearch, Autocomplete,
|
|
15
|
+
exports[`Options without template throws 1`] = `"The template directory must contain a configuration file \`.template.js\` or must be one of those: Angular InstantSearch, Autocomplete, InstantSearch Android, InstantSearch iOS, InstantSearch.js, InstantSearch.js widget, JavaScript Client, JavaScript Helper, React InstantSearch, React InstantSearch Native, Vue InstantSearch, Vue InstantSearch with Vue 3"`;
|
|
@@ -29,34 +29,6 @@ describe('resolveTemplate', () => {
|
|
|
29
29
|
).toBe(path.resolve('src/templates/InstantSearch.js'));
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
-
test('selects the right template with InstantSearch.js template and version 2', () => {
|
|
33
|
-
expect(
|
|
34
|
-
resolveTemplate(
|
|
35
|
-
{
|
|
36
|
-
template: 'InstantSearch.js',
|
|
37
|
-
libraryVersion: '2.10.0',
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
supportedTemplates: ['InstantSearch.js 2'],
|
|
41
|
-
}
|
|
42
|
-
)
|
|
43
|
-
).toBe(path.resolve('src/templates/InstantSearch.js 2'));
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
test('selects the selected template for Vue v1', () => {
|
|
47
|
-
expect(
|
|
48
|
-
resolveTemplate(
|
|
49
|
-
{
|
|
50
|
-
template: 'Vue InstantSearch',
|
|
51
|
-
libraryVersion: '1.7.0',
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
supportedTemplates: ['Vue InstantSearch', 'Vue InstantSearch 1'],
|
|
55
|
-
}
|
|
56
|
-
)
|
|
57
|
-
).toBe(path.resolve('src/templates/Vue InstantSearch 1'));
|
|
58
|
-
});
|
|
59
|
-
|
|
60
32
|
test('throws with unsupported version', () => {
|
|
61
33
|
expect(() =>
|
|
62
34
|
resolveTemplate(
|
|
@@ -4,35 +4,8 @@ const semver = require('semver');
|
|
|
4
4
|
|
|
5
5
|
const { getAppTemplateConfig } = require('../utils');
|
|
6
6
|
|
|
7
|
-
function getTemplateNameByLibraryVersion({
|
|
8
|
-
template = '',
|
|
9
|
-
libraryVersion = '',
|
|
10
|
-
}) {
|
|
11
|
-
const templateName = path.basename(template);
|
|
12
|
-
|
|
13
|
-
if (
|
|
14
|
-
templateName === 'InstantSearch.js' &&
|
|
15
|
-
semver.satisfies(libraryVersion, '>= 2.0.0 < 3.0.0', {
|
|
16
|
-
includePrerelease: true,
|
|
17
|
-
})
|
|
18
|
-
) {
|
|
19
|
-
return 'InstantSearch.js 2';
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (
|
|
23
|
-
templateName === 'Vue InstantSearch' &&
|
|
24
|
-
semver.satisfies(libraryVersion, '>= 1.0.0 < 2.0.0', {
|
|
25
|
-
includePrerelease: true,
|
|
26
|
-
})
|
|
27
|
-
) {
|
|
28
|
-
return 'Vue InstantSearch 1';
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return template;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
7
|
module.exports = function resolveTemplate(options, { supportedTemplates }) {
|
|
35
|
-
const templateName =
|
|
8
|
+
const templateName = options.template || '';
|
|
36
9
|
const templatePath = path.resolve('src/templates', templateName || '');
|
|
37
10
|
let supportedVersion;
|
|
38
11
|
|
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
/node_modules
|
|
5
|
-
|
|
6
|
-
# testing
|
|
7
|
-
/coverage
|
|
8
|
-
|
|
9
|
-
# production
|
|
10
|
-
/build
|
|
11
|
-
|
|
12
|
-
# misc
|
|
13
|
-
.DS_Store
|
|
14
|
-
.env.local
|
|
15
|
-
.env.development.local
|
|
16
|
-
.env.test.local
|
|
17
|
-
.env.production.local
|
|
18
|
-
|
|
1
|
+
# Logs
|
|
2
|
+
logs
|
|
3
|
+
*.log
|
|
19
4
|
npm-debug.log*
|
|
20
5
|
yarn-debug.log*
|
|
21
6
|
yarn-error.log*
|
|
7
|
+
pnpm-debug.log*
|
|
8
|
+
lerna-debug.log*
|
|
9
|
+
|
|
10
|
+
node_modules
|
|
11
|
+
dist
|
|
12
|
+
.parcel-cache
|
|
13
|
+
*.local
|
|
14
|
+
|
|
15
|
+
# Editor directories and files
|
|
16
|
+
.vscode
|
|
17
|
+
.idea
|
|
18
|
+
.DS_Store
|
|
19
|
+
*.suo
|
|
20
|
+
*.ntvs*
|
|
21
|
+
*.njsproj
|
|
22
|
+
*.sln
|
|
23
|
+
*.sw?
|
|
@@ -3,10 +3,11 @@ const teardown = require('../../tasks/node/teardown');
|
|
|
3
3
|
|
|
4
4
|
module.exports = {
|
|
5
5
|
category: 'Web',
|
|
6
|
-
libraryName: 'react-instantsearch
|
|
7
|
-
supportedVersion: '>=
|
|
6
|
+
libraryName: 'react-instantsearch',
|
|
7
|
+
supportedVersion: '>= 7.0.0 < 8.0.0',
|
|
8
8
|
flags: {
|
|
9
|
-
dynamicWidgets: '>=
|
|
9
|
+
dynamicWidgets: '>=7.0',
|
|
10
|
+
insights: '>=7.0',
|
|
10
11
|
},
|
|
11
12
|
templateName: 'react-instantsearch',
|
|
12
13
|
appName: 'react-instantsearch-app',
|
|
@@ -3,32 +3,19 @@
|
|
|
3
3
|
"version": "1.0.0",
|
|
4
4
|
"private": true,
|
|
5
5
|
"scripts": {
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"lint": "eslint .",
|
|
9
|
-
"lint:fix": "npm run lint -- --fix"
|
|
6
|
+
"build": "parcel build index.html",
|
|
7
|
+
"start": "parcel index.html"
|
|
10
8
|
},
|
|
11
9
|
"dependencies": {
|
|
12
10
|
"algoliasearch": "4",
|
|
13
11
|
"react": "18.1.0",
|
|
14
12
|
"react-dom": "18.1.0",
|
|
15
|
-
"react-instantsearch
|
|
16
|
-
"react-scripts": "2.1.1"
|
|
13
|
+
"react-instantsearch": "{{libraryVersion}}"
|
|
17
14
|
},
|
|
18
15
|
"devDependencies": {
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
"eslint-plugin-react": "7.17.0",
|
|
25
|
-
"prettier": "1.19.1",
|
|
26
|
-
"prop-types": "15.7.2"
|
|
27
|
-
},
|
|
28
|
-
"browserslist": [
|
|
29
|
-
">0.2%",
|
|
30
|
-
"not dead",
|
|
31
|
-
"not ie <= 11",
|
|
32
|
-
"not op_mini all"
|
|
33
|
-
]
|
|
16
|
+
"@types/react": "18.0.15",
|
|
17
|
+
"@types/react-dom": "18.0.6",
|
|
18
|
+
"parcel": "2.5.0",
|
|
19
|
+
"typescript": "4.7.4"
|
|
20
|
+
}
|
|
34
21
|
}
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
body,
|
|
2
|
+
h1 {
|
|
3
|
+
margin: 0;
|
|
4
|
+
padding: 0;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
body {
|
|
8
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica,
|
|
9
|
+
Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
|
|
10
|
+
}
|
|
11
|
+
|
|
1
12
|
em {
|
|
2
13
|
background: cyan;
|
|
3
14
|
font-style: normal;
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
RefinementList,
|
|
19
19
|
{{/if}}
|
|
20
20
|
SearchBox,
|
|
21
|
-
} from 'react-instantsearch
|
|
21
|
+
} from 'react-instantsearch';
|
|
22
22
|
|
|
23
23
|
import { Panel } from './Panel';
|
|
24
24
|
|
|
@@ -40,8 +40,8 @@ export function App() {
|
|
|
40
40
|
</h1>
|
|
41
41
|
<p className="header-subtitle">
|
|
42
42
|
using{' '}
|
|
43
|
-
<a href="https://github.com/algolia/instantsearch/tree/master/packages/react-instantsearch
|
|
44
|
-
React InstantSearch
|
|
43
|
+
<a href="https://github.com/algolia/instantsearch/tree/master/packages/react-instantsearch">
|
|
44
|
+
React InstantSearch
|
|
45
45
|
</a>
|
|
46
46
|
</p>
|
|
47
47
|
</header>
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
# expo
|
|
1
|
+
node_modules/
|
|
4
2
|
.expo/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
yarn-error.log*
|
|
3
|
+
dist/
|
|
4
|
+
npm-debug.*
|
|
5
|
+
*.jks
|
|
6
|
+
*.p8
|
|
7
|
+
*.p12
|
|
8
|
+
*.key
|
|
9
|
+
*.mobileprovision
|
|
10
|
+
*.orig.*
|
|
11
|
+
web-build/
|
|
12
|
+
|
|
13
|
+
# macOS
|
|
14
|
+
.DS_Store
|
|
@@ -4,7 +4,8 @@ const teardown = require('../../tasks/node/teardown');
|
|
|
4
4
|
|
|
5
5
|
module.exports = {
|
|
6
6
|
category: 'Mobile',
|
|
7
|
-
libraryName: 'react-instantsearch-
|
|
7
|
+
libraryName: 'react-instantsearch-core',
|
|
8
|
+
supportedVersion: '>= 7.0.0 < 8.0.0',
|
|
8
9
|
templateName: 'react-instantsearch-native',
|
|
9
10
|
appName: 'react-instantsearch-native-app',
|
|
10
11
|
keywords: [
|
package/src/templates/{React InstantSearch Hooks Native → React InstantSearch Native}/App.tsx.hbs
RENAMED
|
@@ -2,7 +2,7 @@ import React, { useRef } from 'react';
|
|
|
2
2
|
import { FlatList, SafeAreaView, StyleSheet, Text, View } from 'react-native';
|
|
3
3
|
import { StatusBar } from 'expo-status-bar';
|
|
4
4
|
import algoliasearch from 'algoliasearch/lite';
|
|
5
|
-
import { InstantSearch } from 'react-instantsearch-
|
|
5
|
+
import { InstantSearch } from 'react-instantsearch-core';
|
|
6
6
|
|
|
7
7
|
import { InfiniteHits } from './src/InfiniteHits';
|
|
8
8
|
import { SearchBox } from './src/SearchBox';
|
|
@@ -2,6 +2,29 @@
|
|
|
2
2
|
"expo": {
|
|
3
3
|
"name": "{{name}}",
|
|
4
4
|
"slug": "{{name}}",
|
|
5
|
-
"
|
|
5
|
+
"version": "1.0.0",
|
|
6
|
+
"orientation": "portrait",
|
|
7
|
+
"icon": "./assets/icon.png",
|
|
8
|
+
"splash": {
|
|
9
|
+
"image": "./assets/splash.png",
|
|
10
|
+
"resizeMode": "contain",
|
|
11
|
+
"backgroundColor": "#ffffff"
|
|
12
|
+
},
|
|
13
|
+
"updates": {
|
|
14
|
+
"fallbackToCacheTimeout": 0
|
|
15
|
+
},
|
|
16
|
+
"assetBundlePatterns": ["**/*"],
|
|
17
|
+
"ios": {
|
|
18
|
+
"supportsTablet": true
|
|
19
|
+
},
|
|
20
|
+
"android": {
|
|
21
|
+
"adaptiveIcon": {
|
|
22
|
+
"foregroundImage": "./assets/adaptive-icon.png",
|
|
23
|
+
"backgroundColor": "#FFFFFF"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"web": {
|
|
27
|
+
"favicon": "./assets/favicon.png"
|
|
28
|
+
}
|
|
6
29
|
}
|
|
7
30
|
}
|
|
@@ -7,26 +7,24 @@
|
|
|
7
7
|
"start": "expo start",
|
|
8
8
|
"android": "expo start --android",
|
|
9
9
|
"ios": "expo start --ios",
|
|
10
|
+
"web": "expo start --web",
|
|
10
11
|
"eject": "expo eject"
|
|
11
12
|
},
|
|
12
13
|
"dependencies": {
|
|
13
|
-
"algoliasearch": "4",
|
|
14
|
-
"expo": "44.0.
|
|
15
|
-
"
|
|
16
|
-
"react": "17.0.
|
|
17
|
-
"react-
|
|
18
|
-
"react-
|
|
14
|
+
"algoliasearch": "4.12.1",
|
|
15
|
+
"expo": "~44.0.0",
|
|
16
|
+
"expo-status-bar": "~1.2.0",
|
|
17
|
+
"react": "17.0.1",
|
|
18
|
+
"react-dom": "17.0.1",
|
|
19
|
+
"react-instantsearch-core": "{{libraryVersion}}",
|
|
20
|
+
"react-native": "0.64.3",
|
|
21
|
+
"react-native-web": "0.17.1"
|
|
19
22
|
},
|
|
20
23
|
"devDependencies": {
|
|
21
|
-
"@babel/core": "7.
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"eslint-plugin-import": "2.25.3",
|
|
27
|
-
"eslint-plugin-prettier": "4.0.0",
|
|
28
|
-
"eslint-plugin-react": "7.28.0",
|
|
29
|
-
"expo-cli": "5.0.3",
|
|
30
|
-
"prettier": "2.5.1"
|
|
24
|
+
"@babel/core": "^7.12.9",
|
|
25
|
+
"@types/react": "~17.0.21",
|
|
26
|
+
"@types/react-native": "~0.64.12",
|
|
27
|
+
"expo-cli": "5.5.1",
|
|
28
|
+
"typescript": "~4.3.5"
|
|
31
29
|
}
|
|
32
30
|
}
|
|
@@ -4,7 +4,7 @@ import { Hit as AlgoliaHit } from '@algolia/client-search';
|
|
|
4
4
|
import {
|
|
5
5
|
useInfiniteHits,
|
|
6
6
|
UseInfiniteHitsProps,
|
|
7
|
-
} from 'react-instantsearch-
|
|
7
|
+
} from 'react-instantsearch-core';
|
|
8
8
|
|
|
9
9
|
type InfiniteHitsProps<THit> = UseInfiniteHitsProps & {
|
|
10
10
|
hitComponent: (props: { hit: THit }) => JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { StyleSheet, View, TextInput } from 'react-native';
|
|
3
|
-
import { useSearchBox, UseSearchBoxProps } from 'react-instantsearch-
|
|
3
|
+
import { useSearchBox, UseSearchBoxProps } from 'react-instantsearch-core';
|
|
4
4
|
|
|
5
5
|
type SearchBoxProps = UseSearchBoxProps & {
|
|
6
6
|
onChange: (newValue: string) => void;
|
|
@@ -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
|
+
});
|
|
@@ -16,9 +16,12 @@ describe('checkAppName', () => {
|
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
test('throws with correct error message', () => {
|
|
19
|
-
expect(() =>
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
expect(() => utils.checkAppName('./project-name'))
|
|
20
|
+
.toThrowErrorMatchingInlineSnapshot(`
|
|
21
|
+
"Could not create a project called \\"<red>./project-name</color>\\" because of npm naming restrictions.
|
|
22
|
+
- name cannot start with a period
|
|
23
|
+
- name can only contain URL-friendly characters"
|
|
24
|
+
`);
|
|
22
25
|
});
|
|
23
26
|
});
|
|
24
27
|
|
|
@@ -48,7 +51,7 @@ describe('checkAppPath', () => {
|
|
|
48
51
|
expect(() =>
|
|
49
52
|
utils.checkAppPath('path')
|
|
50
53
|
).toThrowErrorMatchingInlineSnapshot(
|
|
51
|
-
`"Could not create project in destination folder \\"
|
|
54
|
+
`"Could not create project in destination folder \\"<red>path</color>\\" because it is not empty."`
|
|
52
55
|
);
|
|
53
56
|
});
|
|
54
57
|
|
|
@@ -71,7 +74,7 @@ describe('checkAppPath', () => {
|
|
|
71
74
|
expect(() =>
|
|
72
75
|
utils.checkAppPath('path')
|
|
73
76
|
).toThrowErrorMatchingInlineSnapshot(
|
|
74
|
-
`"Could not create project at path
|
|
77
|
+
`"Could not create project at path <red>path</color> because a file of the same name already exists."`
|
|
75
78
|
);
|
|
76
79
|
});
|
|
77
80
|
|
|
@@ -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
|
@@ -2,22 +2,13 @@ const { execSync } = require('child_process');
|
|
|
2
2
|
const fs = require('fs');
|
|
3
3
|
const path = require('path');
|
|
4
4
|
|
|
5
|
-
const algoliasearch = require('algoliasearch');
|
|
6
5
|
const chalk = require('chalk');
|
|
7
6
|
const semver = require('semver');
|
|
8
7
|
const validateProjectName = require('validate-npm-package-name');
|
|
9
8
|
|
|
9
|
+
const { fetchLibraryVersions } = require('./fetchLibraryVersions');
|
|
10
10
|
const TEMPLATES_FOLDER = path.join(__dirname, '../templates');
|
|
11
11
|
|
|
12
|
-
const algoliaConfig = {
|
|
13
|
-
appId: 'OFCNCOG2CU',
|
|
14
|
-
apiKey: 'f54e21fa3a2a0160595bb058179bfb1e',
|
|
15
|
-
indexName: 'npm-search',
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const client = algoliasearch(algoliaConfig.appId, algoliaConfig.apiKey);
|
|
19
|
-
const index = client.initIndex(algoliaConfig.indexName);
|
|
20
|
-
|
|
21
12
|
function checkAppName(appName) {
|
|
22
13
|
const validationResult = validateProjectName(appName);
|
|
23
14
|
|
|
@@ -130,14 +121,6 @@ function getTemplatePath(templateName) {
|
|
|
130
121
|
return templateName;
|
|
131
122
|
}
|
|
132
123
|
|
|
133
|
-
async function fetchLibraryVersions(libraryName) {
|
|
134
|
-
const library = await index.getObject(libraryName, {
|
|
135
|
-
attributesToRetrieve: ['versions'],
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
return Object.keys(library.versions).reverse();
|
|
139
|
-
}
|
|
140
|
-
|
|
141
124
|
function getLibraryVersion({ libraryName, supportedVersion = '' }) {
|
|
142
125
|
return async (getVersion) => {
|
|
143
126
|
const versions = await fetchLibraryVersions(libraryName);
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# See https://help.github.com/ignore-files/ for more about ignoring files.
|
|
2
|
-
|
|
3
|
-
# dependencies
|
|
4
|
-
/node_modules
|
|
5
|
-
|
|
6
|
-
# testing
|
|
7
|
-
/coverage
|
|
8
|
-
|
|
9
|
-
# production
|
|
10
|
-
/dist
|
|
11
|
-
/.cache
|
|
12
|
-
|
|
13
|
-
# misc
|
|
14
|
-
.DS_Store
|
|
15
|
-
.env.local
|
|
16
|
-
.env.development.local
|
|
17
|
-
.env.test.local
|
|
18
|
-
.env.production.local
|
|
19
|
-
|
|
20
|
-
npm-debug.log*
|
|
21
|
-
yarn-debug.log*
|
|
22
|
-
yarn-error.log*
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
const install = require('../../tasks/node/install');
|
|
2
|
-
const teardown = require('../../tasks/node/teardown');
|
|
3
|
-
|
|
4
|
-
module.exports = {
|
|
5
|
-
libraryName: 'autocomplete.js',
|
|
6
|
-
templateName: 'autocomplete.js-0.x',
|
|
7
|
-
appName: 'autocomplete.js-app',
|
|
8
|
-
keywords: ['algolia', 'Autocomplete', 'autocomplete.js'],
|
|
9
|
-
tasks: {
|
|
10
|
-
install,
|
|
11
|
-
teardown,
|
|
12
|
-
},
|
|
13
|
-
};
|