lamdera 0.19.1-1.1.1

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/bin/lamdera ADDED
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env node
2
+
3
+ var child_process = require('child_process');
4
+
5
+
6
+ // Some npm users enable --ignore-scripts (a good security measure) so
7
+ // they do not run the post-install hook and install.js does not run.
8
+ // Instead they will run this script.
9
+ //
10
+ // On Mac and Linux, we hard link the lamdera executable into the exact same
11
+ // location as this file. Since npm uses symlinks on these platforms,
12
+ // that means that the first run will invoke this file and subsequent
13
+ // runs will call the lamdera binary directly.
14
+ //
15
+ // On Windows, our binary file must be named lamdera.exe for it to run properly.
16
+ // Instead of symlinks, npm creates two files:
17
+ //
18
+ // - node_modules/.bin/lamdera (a bash file)
19
+ // - node_modules/.bin/lamdera.cmd (a batch file)
20
+ //
21
+ // Both files specifically invoke `node` to run the file listed at package.bin,
22
+ // so there is no way around instantiating node for no reason on Windows.
23
+
24
+
25
+ var binaryPath = require('../binary.js')();
26
+ child_process
27
+ .spawn(binaryPath, process.argv.slice(2), { stdio: 'inherit' })
28
+ .on('exit', process.exit);
package/binary.js ADDED
@@ -0,0 +1,125 @@
1
+ var fs = require('fs');
2
+ var package = require('./package.json');
3
+ var path = require('path');
4
+
5
+
6
+
7
+ // MAIN
8
+ //
9
+ // This function is used by install.js and by the bin/lamdera backup that gets
10
+ // called when --ignore-scripts is enabled.
11
+
12
+
13
+ module.exports = function()
14
+ {
15
+ // figure out package of binary
16
+ // turn '0.19.1-1.2.3-alpha' into '0.19.1-1.2.3'
17
+ var version = package.version.replace(/^(\d+\.\d+\.\d+)-(\d+\.\d+\.\d+).*$/, '$1');
18
+ var subPackageName = 'lamdera-' + process.platform + '-' + process.arch;
19
+
20
+ verifyPlatform(version, subPackageName);
21
+
22
+ var fileName = process.platform === 'win32' ? 'lamdera.exe' : 'lamdera';
23
+
24
+ try
25
+ {
26
+ var subBinaryPath = require.resolve(subPackageName + '/' + fileName);
27
+ }
28
+ catch (error)
29
+ {
30
+ if (error && error.code === 'MODULE_NOT_FOUND')
31
+ {
32
+ exitFailure(version, missingSubPackageHelp(subPackageName));
33
+ }
34
+ else
35
+ {
36
+ exitFailure(version, 'I had trouble requiring the binary package for your platform (' + subPackageName + '):\n\n' + error);
37
+ }
38
+ }
39
+
40
+ // Yarn 2 and later ("Berry") always invokes `node` (regardless of configuration)
41
+ // so we cannot do any optimizations there
42
+ var isYarnBerry = /\byarn\/(?!1\.)/.test(process.env.npm_config_user_agent || "");
43
+
44
+ // as mentioned in bin/lamdera we cannot do any optimizations on Windows
45
+ if (process.platform === 'win32' || isYarnBerry)
46
+ {
47
+ return subBinaryPath;
48
+ }
49
+
50
+ // figure out where to put the binary
51
+ var binaryPath = path.resolve(__dirname, package.bin.lamdera);
52
+ var tmpPath = binaryPath + '.tmp';
53
+
54
+ // optimize by replacing the JS bin/lamdera with the native binary directly
55
+ try
56
+ {
57
+ // atomically replace the file with a hard link to the binary
58
+ fs.linkSync(subBinaryPath, tmpPath);
59
+ fs.renameSync(tmpPath, binaryPath);
60
+ }
61
+ catch (error)
62
+ {
63
+ exitFailure(version, 'I had some trouble writing file to disk. It is saying:\n\n' + error);
64
+ }
65
+
66
+ return binaryPath;
67
+ }
68
+
69
+
70
+
71
+ // VERIFY PLATFORM
72
+
73
+
74
+ function verifyPlatform(version, subPackageName)
75
+ {
76
+ if (subPackageName in package.optionalDependencies) return;
77
+
78
+ var situation = process.platform + '_' + process.arch;
79
+ console.error(
80
+ '-- ERROR -----------------------------------------------------------------------\n\n'
81
+ + 'The lamdera npm package does not support your platform (' + situation + ').\n\n'
82
+ + 'You can try to manually download an appropriate binary (if there is one) from:\n'
83
+ + 'https://dashboard.lamdera.app/docs/download\n\n'
84
+ + 'Or otherwise asking for help on the Lamdera Discord:\n'
85
+ + 'https://dashboard.lamdera.app/docs/discuss\n\n'
86
+ + '--------------------------------------------------------------------------------\n'
87
+ );
88
+ process.exit(1);
89
+ }
90
+
91
+
92
+
93
+ // EXIT FAILURE
94
+
95
+
96
+ function exitFailure(version, message)
97
+ {
98
+ console.error(
99
+ '-- ERROR -----------------------------------------------------------------------\n\n'
100
+ + message
101
+ + '\n\nNOTE: You can avoid npm entirely by downloading directly from:\n'
102
+ + 'https://dashboard.lamdera.app/docs/download\n'
103
+ + 'All this package does is distribute a file from there.\n\n'
104
+ + '--------------------------------------------------------------------------------\n'
105
+ );
106
+ process.exit(1);
107
+ }
108
+
109
+
110
+
111
+ // MISSING SUB PACKAGE HELP
112
+
113
+
114
+ function missingSubPackageHelp(subPackageName)
115
+ {
116
+ return (
117
+ 'I support your platform, but I could not find the binary package (' + subPackageName + ') for it!\n\n'
118
+ + 'This can happen if you use the "--omit=optional" (or "--no-optional") npm flag.\n'
119
+ + 'The "optionalDependencies" package.json feature is used by Lamdera to install the correct\n'
120
+ + 'binary executable for your current platform. Remove that flag to use Lamdera.\n\n'
121
+ + 'This can also happen if the "node_modules" folder was copied between two operating systems\n'
122
+ + 'that need different binaries - including "virtual" operating systems like Docker and WSL.\n'
123
+ + 'If so, try installing with npm rather than copying "node_modules".'
124
+ );
125
+ }
package/install.js ADDED
@@ -0,0 +1 @@
1
+ require('./binary.js')();
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "lamdera",
3
+ "version": "0.19.1-1.1.1",
4
+ "description": "npm install wrapper for Lamdera",
5
+ "license": "BSD-3-Clause",
6
+ "repository": "lamdera/compiler",
7
+ "author": "Mario Rogic",
8
+ "type": "commonjs",
9
+ "exports": {},
10
+ "scripts": {
11
+ "install": "node install.js"
12
+ },
13
+ "files": [
14
+ "install.js",
15
+ "binary.js",
16
+ "bin",
17
+ "bin/lamdera"
18
+ ],
19
+ "keywords": [
20
+ "bin",
21
+ "binary",
22
+ "binaries",
23
+ "lamdera",
24
+ "install",
25
+ "installer"
26
+ ],
27
+ "bin": {
28
+ "lamdera": "bin/lamdera"
29
+ },
30
+ "optionalDependencies": {
31
+ "lamdera-darwin-arm64": "0.19.1-1.1.1",
32
+ "lamdera-darwin-x64": "0.19.1-1.1.1",
33
+ "lamdera-linux-arm": "0.19.1-1.1.1",
34
+ "lamdera-linux-arm64": "0.19.1-1.1.1",
35
+ "lamdera-linux-x64": "0.19.1-1.1.1",
36
+ "lamdera-win32-x64": "0.19.1-1.1.1"
37
+ }
38
+ }
package/readme.md ADDED
@@ -0,0 +1,55 @@
1
+ # Lamdera NPM Installer
2
+
3
+ [Lamdera](https://lamdera.com) is a delightful platform for full-stack web apps built with [Elm](https://elm-lang.org/).
4
+
5
+ The Lamdera compiler is a super-set of the Elm compiler and a drop-in replacement: you can use `lamdera` on your existing non-Lamdera Elm projects in the same way you use `elm`.
6
+
7
+ Beware of [Elm IDE gotchas](https://dashboard.lamdera.app/docs/ides-and-tooling), you'll need to set Lamdera as your Elm compiler.
8
+
9
+
10
+ <br/>
11
+
12
+ ## What is this package for?
13
+
14
+ **Normal installs** ❌
15
+
16
+ Use the instructions [here](https://dashboard.lamdera.app/docs/download) instead.
17
+
18
+ Lamdera has no dependency on `npm` to develop locally, so there's no reason to introduce it unless you specifically want to use `npm` for other reasons.
19
+
20
+ **Tooling author** ✅
21
+
22
+ If you're a tooling author, use Lamdera as a dependency and npm as a distribution method, then you can use this package to manage the dependency and installation.
23
+
24
+ ```
25
+ npm install --save-dev lamdera@latest
26
+ ```
27
+
28
+ **Multiple versions** ⚠️
29
+
30
+ If you're a tooling author, use Lamdera as a dependency and npm as a distribution method, then you can
31
+
32
+ You could also use this package to use different versions of Lamdera in different projects. I.e. `npm install lamdera@latest` in each project and use the binary at `./node_modules/.bin/lamdera` for compilation. However this is generally not recommended. Lamdera users should always use the latest release, as that's what is used when you do a `lamdera deploy`.
33
+
34
+
35
+ **Continuous integration** ⚠️
36
+
37
+ This works, but there are usually faster and more reliable options:
38
+
39
+ 1. You can download `lamdera` directly from [the downloads page](https://dashboard.lamdera.app/docs/download). This is all the `npm` installer does, but with extra HTTP requests to `npmjs.com` servers, making it slower and adding more failure points.
40
+ 2. Many continuous integration pipelines ways to cache files ([example](https://docs.travis-ci.com/user/caching/)) to make builds faster and more reliable.
41
+
42
+ That said, it will definitely work to use the `npm` installer on CI if you prefer that option.
43
+
44
+
45
+ <br/>
46
+
47
+ ## Install Locally
48
+
49
+ The following command should download the latest Lamdera binary:
50
+
51
+ ```
52
+ npm install lamdera@latest
53
+ ```
54
+
55
+ You should be able to run `npx lamdera --version` within your project and see `0.19.1` (the base Elm version), or `--version-full` to see the full Elm + Lamdera release version. Now you can develop with `npx lamdera live`.