Procházet zdrojové kódy

npm run build

master
Garrick Aden-Buie před 6 roky
rodič
revize
7abf022434
5 změnil soubory, kde provedl 1858 přidání a 1 odebrání
  1. +45
    -0
      dev/dev.Rmd
  2. +2
    -0
      inst/htmlwidgets/lib/frappe-charts/frappe-charts.min.iife.js
  3. +1
    -0
      inst/htmlwidgets/lib/frappe-charts/frappe-charts.min.iife.js.map
  4. +1805
    -0
      package-lock.json
  5. +5
    -1
      package.json

+ 45
- 0
dev/dev.Rmd Zobrazit soubor

@@ -1,3 +1,7 @@
```{r setup, include=FALSE}
knitr::opts_chunk$set(eval = FALSE)
```

## Setup R Package

Create a package for this HTML widget.
@@ -90,3 +94,44 @@ and creates a file `R/frappeChart.R` with the functions
- `frappeChart()`
- `frappeChartOutput()` (for shiny)
- `renderFrappeChart()` (for shiny)

## Use `npm` to get our dependencies in the right place

`htmlwidgets` load dependencies in a way that's exactly the same as using a
`<script>` tag in the HTML `<head>`.
Look at the documentation on Frappe Charts and decide which file we should use.

Here's the block from their docs

```
<script src="https://cdn.jsdelivr.net/npm/frappe-charts@1.2.4/dist/frappe-charts.min.iife.js"></script>
<!-- or -->
<script src="https://unpkg.com/frappe-charts@1.2.4/dist/frappe-charts.min.iife.js"></script>
```

We need to get our dependecy into a subfolder of `inst/htmlwidgets`.
Convention is `inst/htmlwidgets/lib/<dependency_name>`.
Rather than creating the directoy and copying over, etc.,
we can have an `npm` build script do this for us.

To avoid issues with mac/windows,
we'll add a dev dependency on [`cpy-cli`](https://github.com/sindresorhus/cpy-cli)

```bash
npm install cpy-cli --save-dev
```

and

```{r create-lib-dir}
dir.create("inst/htmlwidets/lib/frappe-charts", recursive = TRUE)
```

and then edit `package.json` to add copy tasks

```
"scripts": {
"copy-js": "cpy 'node_modules/frappe-charts/dist/frappe-charts.min.iife*' inst/htmlwidgets/lib/frappe-charts/",
"build": "npm run copy-js"
}
```

+ 2
- 0
inst/htmlwidgets/lib/frappe-charts/frappe-charts.min.iife.js
Diff nebyl zobrazen, protože je příliš veliký
Zobrazit soubor


+ 1
- 0
inst/htmlwidgets/lib/frappe-charts/frappe-charts.min.iife.js.map
Diff nebyl zobrazen, protože je příliš veliký
Zobrazit soubor


+ 1805
- 0
package-lock.json
Diff nebyl zobrazen, protože je příliš veliký
Zobrazit soubor


+ 5
- 1
package.json Zobrazit soubor

@@ -4,11 +4,15 @@
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"copy-js": "cpy 'node_modules/frappe-charts/dist/frappe-charts.min.iife*' inst/htmlwidgets/lib/frappe-charts/",
"build": "npm run copy-js"
},
"author": "",
"license": "MIT",
"dependencies": {
"frappe-charts": "^1.3.0"
},
"devDependencies": {
"cpy-cli": "^3.0.0"
}
}

Načítá se…
Zrušit
Uložit