local-storefront 0.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/README.md +34 -0
- package/bin/lsf.js +49 -0
- package/package.json +38 -0
package/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# local-storefront
|
|
2
|
+
|
|
3
|
+
A local storefront for Shopify themes. Its command, `lsf`, serves a theme from your machine,
|
|
4
|
+
rendered from JSON fixtures instead of the Shopify API: no network, no rate limit, and each
|
|
5
|
+
test gets exactly the catalog, cart and customer it asks for.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install --save-dev local-storefront
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npx lsf serve
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
With Playwright:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
// playwright.config.ts
|
|
19
|
+
import { defineConfig } from '@playwright/test';
|
|
20
|
+
|
|
21
|
+
export default defineConfig({
|
|
22
|
+
use: { baseURL: 'http://127.0.0.1:9292' },
|
|
23
|
+
webServer: {
|
|
24
|
+
command: 'npx lsf serve --port 9292 --static --quiet --strict',
|
|
25
|
+
url: 'http://127.0.0.1:9292/__lsf/status',
|
|
26
|
+
reuseExistingServer: !process.env.CI,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
This package only contains a launcher. The `lsf` binary comes from a platform package that
|
|
32
|
+
npm installs alongside it: macOS, Linux and Windows, on x64 and arm64.
|
|
33
|
+
|
|
34
|
+
Documentation: <https://github.com/0xtlt/local-storefront>
|
package/bin/lsf.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
// Runs the lsf binary npm installed for this platform, passing everything through.
|
|
5
|
+
//
|
|
6
|
+
// The binary lives in a package of its own, `local-storefront-<platform>-<arch>`, listed in
|
|
7
|
+
// the optional dependencies of this one: npm installs the one that matches the machine.
|
|
8
|
+
|
|
9
|
+
const { spawn } = require('node:child_process');
|
|
10
|
+
|
|
11
|
+
const SUPPORTED = ['darwin-arm64', 'darwin-x64', 'linux-arm64', 'linux-x64', 'win32-arm64', 'win32-x64'];
|
|
12
|
+
|
|
13
|
+
const platform = `${process.platform}-${process.arch}`;
|
|
14
|
+
const name = `local-storefront-${platform}`;
|
|
15
|
+
const file = process.platform === 'win32' ? 'lsf.exe' : 'lsf';
|
|
16
|
+
|
|
17
|
+
let binary;
|
|
18
|
+
try {
|
|
19
|
+
binary = require.resolve(`${name}/bin/${file}`);
|
|
20
|
+
} catch {
|
|
21
|
+
const reason = SUPPORTED.includes(platform)
|
|
22
|
+
? `The package ${name} is not installed. It is an optional dependency: reinstall without\n` +
|
|
23
|
+
'--omit=optional (npm) or --no-optional (yarn, pnpm).'
|
|
24
|
+
: `There is no build for ${platform}. Supported: ${SUPPORTED.join(', ')}.`;
|
|
25
|
+
console.error(`local-storefront: cannot find the lsf binary.\n${reason}`);
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const child = spawn(binary, process.argv.slice(2), { stdio: 'inherit' });
|
|
30
|
+
|
|
31
|
+
// A runner that stops this process (Playwright's webServer, a CI step) must stop the server.
|
|
32
|
+
const signals = ['SIGINT', 'SIGTERM', 'SIGHUP'];
|
|
33
|
+
const forward = (signal) => child.kill(signal);
|
|
34
|
+
for (const signal of signals) process.on(signal, forward);
|
|
35
|
+
|
|
36
|
+
child.on('error', (error) => {
|
|
37
|
+
console.error(`local-storefront: cannot run ${binary}: ${error.message}`);
|
|
38
|
+
process.exit(1);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
child.on('exit', (code, signal) => {
|
|
42
|
+
if (signal) {
|
|
43
|
+
// End the same way the binary did, so that the caller sees the signal.
|
|
44
|
+
for (const name of signals) process.removeListener(name, forward);
|
|
45
|
+
process.kill(process.pid, signal);
|
|
46
|
+
} else {
|
|
47
|
+
process.exit(code ?? 1);
|
|
48
|
+
}
|
|
49
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "local-storefront",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "A local storefront for Shopify themes: lsf renders a theme from JSON fixtures, without the Shopify API, for fast end-to-end tests.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"shopify",
|
|
7
|
+
"theme",
|
|
8
|
+
"liquid",
|
|
9
|
+
"storefront",
|
|
10
|
+
"e2e",
|
|
11
|
+
"testing",
|
|
12
|
+
"playwright"
|
|
13
|
+
],
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"homepage": "https://github.com/0xtlt/local-storefront#readme",
|
|
16
|
+
"bugs": "https://github.com/0xtlt/local-storefront/issues",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/0xtlt/local-storefront.git"
|
|
20
|
+
},
|
|
21
|
+
"bin": {
|
|
22
|
+
"lsf": "bin/lsf.js"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"bin/lsf.js"
|
|
26
|
+
],
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=18"
|
|
29
|
+
},
|
|
30
|
+
"optionalDependencies": {
|
|
31
|
+
"local-storefront-darwin-arm64": "0.1.1",
|
|
32
|
+
"local-storefront-darwin-x64": "0.1.1",
|
|
33
|
+
"local-storefront-linux-arm64": "0.1.1",
|
|
34
|
+
"local-storefront-linux-x64": "0.1.1",
|
|
35
|
+
"local-storefront-win32-arm64": "0.1.1",
|
|
36
|
+
"local-storefront-win32-x64": "0.1.1"
|
|
37
|
+
}
|
|
38
|
+
}
|