Skip to content

Commit

Permalink
feat: prepare rename to algoliasearch-netlify (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerska authored Sep 22, 2020
1 parent 5feafa9 commit d3ccb96
Show file tree
Hide file tree
Showing 15 changed files with 129 additions and 125 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
dist/
dist/
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
12.16.2
14.11.0
54 changes: 9 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,56 +1,20 @@
> ⚠️ **This project is an alpha, not usable without dedicated access.**
# crawler-netlify-plugin
# Algolia's Netlify integration

This plugin links your Netlify site with Algolia's Crawler.
It will trigger a crawl on each successful build.
This integration links your Netlify site with Algolia.

## Architecture

- [`src/`](./src/): plugin sources
- [`public/`](./public/): test website
- [`app/`](./app/): Front-end library
- [`plugin/`](./plugin/): Netlify plugin sources
- [`public/`](./public/): Test website

## Environment variables
The plugin links your Netlify site to Algolia's Crawler.
It triggers a crawl on each successful build.

- `ALGOLIA_API_KEY` [Optional in dev] API Key to authenticate the call to the crawler.
- `ALGOLIA_BASE_URL` [Optional] Defaults to `https://crawler.algolia.com/`.

For a local run, those need to be set in `.env` using `cp .env.example .env` and modifying the values to fit your needs.

## Scripts

- `yarn dev`: run dev environment
- `yarn release`: build & publish the library
This repository is itself a netlify site, which allows us to test the whole setup.

## Development

### Pre-requisites

**Only accessible to Algolia employees.**

1. Access to the Algolia team on Netlify (only granted to Algolia employees).
2. Access to the test website in this org: https://app.netlify.com/sites/crawler-netlify-plugin/
3. Clone the repo and link it to the test website on Netlify:
```sh
git clone [email protected]:algolia/crawler-netlify-plugin.git
cd crawler-netlify-plugin
yarn
yarn netlify link
# Accept linking it with the current git remote, it'll detect the correct site automatically
```
4. Setup `.env` by copying the example file:
```sh
cp .env.example .env
```
Make sure the values in this file are good.

### Running the dev env

```sh
yarn dev
```

This script creates a temporary `netlify.toml` which references a plugin located at `dist/index.js`.
It then builds the site locally, running the local version of the plugin.

To change the crawler target from the prod one to a locally running on, simply change in your `.env` `ALGOLIA_BASE_URL` to target your local instance.
See each project's respective README.
1 change: 0 additions & 1 deletion manifest.yml

This file was deleted.

8 changes: 1 addition & 7 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,2 @@

# This file is generated by scripts/generate_netlify_toml.sh
# DO NOT MODIFY, MODIFY THE GENERATING SCRIPT


[[plugins]]
package = "@algolia/crawler-netlify-plugin"

package = "./plugin/dist/index.js"
30 changes: 16 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
{
"name": "@algolia/crawler-netlify-plugin",
"version": "0.0.3",
"main": "dist/index.js",
"repository": "https://github.com/algolia/crawler-netlify-plugin.git",
"name": "@algolia/netlify",
"version": "0.0.4",
"private": true,
"author": "Algolia Team <[email protected]>",
"license": "MIT",
"private": false,
"repository": "https://github.com/algolia/algoliasearch-netlify.git",
"workspaces": [
"plugin"
],
"scripts": {
"build": "tsc -b",
"dev": "NODE_ENV=development ./scripts/dev.sh",
"build": "echo 'Website already built in public'",
"build:plugin": "cd plugin && yarn build",
"dev:plugin": "cd plugin && yarn dev",
"lint": "eslint --ext=jsx,ts,tsx,js .",
"release": "yarn build && yarn publish"
"release:plugin": "cd plugin && yarn release"
},
"dependencies": {
"node-fetch": "2.6.0"
"@algolia/crawler-netlify-plugin": "*"
},
"devDependencies": {
"@types/node": "14.0.27",
Expand All @@ -35,9 +38,8 @@
"prettier": "2.1.1",
"typescript": "4.0.2"
},
"files": [
"README.md",
"manifest.yml",
"dist/"
]
"engines": {
"yarn": "1.*",
"node": "14.*"
}
}
49 changes: 49 additions & 0 deletions plugin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# crawler-netlify-plugin

This plugin links your Netlify site with Algolia's Crawler.
It will trigger a crawl on each successful build.

## Environment variables

- `ALGOLIA_API_KEY` [Optional in dev] API Key to authenticate the call to the crawler.
- `ALGOLIA_BASE_URL` [Optional] Defaults to `https://crawler.algolia.com/`.

For a local run, those need to be set in `.env` using `cp .env.example .env` and modifying the values to fit your needs.

## Scripts

- `yarn dev`: run dev environment
- `yarn release`: build & publish the library

## Development

### Pre-requisites

**Only accessible to Algolia employees.**

1. Access to the Algolia team on Netlify (only granted to Algolia employees).
2. Access to the test website in this org: https://app.netlify.com/sites/crawler-netlify-plugin/
3. Clone the repo and link it to the test website on Netlify:
```sh
git clone [email protected]:algolia/algoliasearch-netlify.git
cd algoliasearch-netlify
yarn
yarn netlify link
# Accept linking it with the current git remote, it'll detect the correct site automatically
```
4. Setup `.env` by copying the example file:
```sh
cp .env.example .env
```
Make sure the values in this file are good.

### Running the dev env

```sh
yarn dev
```

This script creates a temporary `netlify.toml` which references a plugin located at `dist/index.js`.
It then builds the site locally, running the local version of the plugin.

To change the crawler target from the prod one to a locally running on, simply change in your `.env` `ALGOLIA_BASE_URL` to target your local instance.
1 change: 1 addition & 0 deletions plugin/manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: crawler-netlify-plugin
24 changes: 24 additions & 0 deletions plugin/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "@algolia/crawler-netlify-plugin",
"version": "0.0.4",
"private": false,
"author": "Algolia Team <[email protected]>",
"license": "MIT",
"repository": "https://github.com/algolia/algoliasearch-netlify.git",
"main": "dist/index.js",
"files": [
"README.md",
"manifest.yml",
"dist/"
],
"scripts": {
"build": "tsc -b",
"dev": "NODE_ENV=development ../scripts/dev_plugin.sh",
"postinstall": "npm run build",
"release": "yarn build && yarn publish"
},
"dependencies": {
"node-fetch": "2.6.0"
},
"devDependencies": {}
}
File renamed without changes.
11 changes: 11 additions & 0 deletions plugin/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
"rootDir": "src",
"baseUrl": ".",
"outDir": "./dist", /* Redirect output structure to the directory. */
},
"include": [
"src"
]
}
21 changes: 0 additions & 21 deletions scripts/dev.sh

This file was deleted.

14 changes: 14 additions & 0 deletions scripts/dev_plugin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#! /bin/bash

set -e

cd "$(dirname "${BASH_SOURCE[0]}")"
cd ..

[ -f .env ] || ( echo 'Missing .env' && exit 1 )
set -a
source .env
set +a

yarn build:plugin
yarn netlify build
31 changes: 0 additions & 31 deletions scripts/generate_netlify_toml.sh

This file was deleted.

6 changes: 2 additions & 4 deletions tsconfig.json → tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "./dist", /* Redirect output structure to the directory. */
// "outDir": "./dist", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
Expand Down Expand Up @@ -59,7 +59,5 @@
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
},
"include": [
"src"
]
"include": []
}

0 comments on commit d3ccb96

Please sign in to comment.