wake-runner 1.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/LICENSE +21 -0
- package/README.md +190 -0
- package/bin/wake-storefront.js +4 -0
- package/bin/wake-tailwind.js +4 -0
- package/bin/wake.js +178 -0
- package/package.json +20 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kelven Souza
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
# wake-runner
|
|
2
|
+
|
|
3
|
+
CLI to start Wake storefront projects from the project root.
|
|
4
|
+
|
|
5
|
+
`wake-runner` automates two common tasks in Wake projects:
|
|
6
|
+
|
|
7
|
+
- Start `fbits.storefront` using the token from `Configs/settings.json`
|
|
8
|
+
- Start `tailwindcss --watch` for every `input*.css` file inside `Assets/CSS/`
|
|
9
|
+
|
|
10
|
+
## Requirements
|
|
11
|
+
|
|
12
|
+
- Node.js installed
|
|
13
|
+
- `fbits.storefront` installed on your machine and available in your PATH
|
|
14
|
+
- Tailwind CSS **3.4.18** installed on your machine (via standalone CLI in PATH or npm)—required for compatibility with the [Wake template padrão](https://wakecommerce.readme.io/docs/template-padrao#tailwindcss)
|
|
15
|
+
- A Wake project containing:
|
|
16
|
+
- `Configs/settings.json`
|
|
17
|
+
- `Assets/CSS/`
|
|
18
|
+
|
|
19
|
+
## External tools
|
|
20
|
+
|
|
21
|
+
Before using `wake-runner`, install the required CLIs on your machine.
|
|
22
|
+
|
|
23
|
+
### `fbits.storefront`
|
|
24
|
+
|
|
25
|
+
`fbits.storefront` is required to start the local Wake Storefront server.
|
|
26
|
+
|
|
27
|
+
Follow the official Wake Commerce installation guide for your operating system:
|
|
28
|
+
|
|
29
|
+
- https://wakecommerce.readme.io/docs/local#download
|
|
30
|
+
|
|
31
|
+
After installation, make sure `fbits.storefront` is available from your terminal.
|
|
32
|
+
|
|
33
|
+
### Tailwind CSS (v3.4.18)
|
|
34
|
+
|
|
35
|
+
The default Wake template uses Tailwind CSS and recommends **version 3.4.18**. You must have this version installed. See the [Wake Commerce – Template Padrão (TailwindCSS)](https://wakecommerce.readme.io/docs/template-padrao#tailwindcss) documentation for details.
|
|
36
|
+
|
|
37
|
+
You can install Tailwind in either of these ways:
|
|
38
|
+
|
|
39
|
+
1. **Standalone CLI (recommended in Wake docs)**
|
|
40
|
+
Download the [Tailwind CSS CLI release v3.4.18](https://github.com/tailwindlabs/tailwindcss/releases/tag/v3.4.18), add the binary to your system PATH, and ensure the `tailwindcss` command is available in your terminal.
|
|
41
|
+
|
|
42
|
+
2. **npm**
|
|
43
|
+
Install globally or in your Wake project:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npm install -g tailwindcss@3.4.18
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Or locally in the Wake project:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
npm install -D tailwindcss@3.4.18
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
When you run `wake tailwind` or `wake`, the CLI will:
|
|
56
|
+
|
|
57
|
+
- use the local npm Tailwind when `node_modules/.bin/tailwindcss` exists in the current project
|
|
58
|
+
- otherwise use the global `tailwindcss` command from your PATH
|
|
59
|
+
|
|
60
|
+
## Expected project structure
|
|
61
|
+
|
|
62
|
+
Run the commands from the root of your Wake project:
|
|
63
|
+
|
|
64
|
+
```text
|
|
65
|
+
your-wake-project/
|
|
66
|
+
├── Configs/
|
|
67
|
+
│ └── settings.json
|
|
68
|
+
└── Assets/
|
|
69
|
+
└── CSS/
|
|
70
|
+
├── input.css
|
|
71
|
+
├── input_login.css
|
|
72
|
+
└── input_checkout.css
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
`settings.json` must contain an `access_token` field:
|
|
76
|
+
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"access_token": "your-token-here"
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Installation
|
|
84
|
+
|
|
85
|
+
Install globally from npm:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
npm install -g wake-runner
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
For local development of this package, inside the package folder:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
npm install -g .
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Usage
|
|
98
|
+
|
|
99
|
+
Go to your Wake project root and run one of the commands below.
|
|
100
|
+
|
|
101
|
+
If you are using a local npm Tailwind installation, run these commands from the same project root where `tailwindcss` was installed.
|
|
102
|
+
|
|
103
|
+
### Start everything
|
|
104
|
+
|
|
105
|
+
Starts `fbits.storefront` and all Tailwind watchers:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
wake
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Start only storefront
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
wake storefront
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Or:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
wake-storefront
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Start only Tailwind watchers
|
|
124
|
+
|
|
125
|
+
Starts one watcher for each `input*.css` file found directly inside `Assets/CSS/`.
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
wake tailwind
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Or:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
wake-tailwind
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## CSS file mapping
|
|
138
|
+
|
|
139
|
+
Each input file is mapped to an output file by replacing the leading `input` prefix with `output`.
|
|
140
|
+
|
|
141
|
+
Examples:
|
|
142
|
+
|
|
143
|
+
- `input.css` -> `output.css`
|
|
144
|
+
- `input_login.css` -> `output_login.css`
|
|
145
|
+
- `input_partner.css` -> `output_partner.css`
|
|
146
|
+
|
|
147
|
+
## How it works
|
|
148
|
+
|
|
149
|
+
### `wake storefront`
|
|
150
|
+
|
|
151
|
+
- Reads `Configs/settings.json`
|
|
152
|
+
- Extracts `access_token`
|
|
153
|
+
- Runs:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
fbits.storefront --token <access_token>
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### `wake tailwind`
|
|
160
|
+
|
|
161
|
+
- Reads files directly from `Assets/CSS/`
|
|
162
|
+
- Finds files that start with `input` and end with `.css`
|
|
163
|
+
- Starts one process per file
|
|
164
|
+
- Uses local npm Tailwind when available, otherwise uses the global `tailwindcss` command:
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
tailwindcss -i ./Assets/CSS/input.css -o ./Assets/CSS/output.css --watch
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Errors
|
|
171
|
+
|
|
172
|
+
The CLI exits with code `1` when:
|
|
173
|
+
|
|
174
|
+
- `Configs/settings.json` does not exist
|
|
175
|
+
- `Configs/settings.json` is invalid JSON
|
|
176
|
+
- `access_token` is missing or empty
|
|
177
|
+
- `Assets/CSS/` does not exist
|
|
178
|
+
- No `input*.css` files are found
|
|
179
|
+
|
|
180
|
+
## Notes
|
|
181
|
+
|
|
182
|
+
- Only files directly inside `Assets/CSS/` are scanned
|
|
183
|
+
- Subdirectories are not scanned
|
|
184
|
+
- The CLI uses only Node.js built-in modules
|
|
185
|
+
- Tailwind 3.4.18 can be installed via the standalone CLI (add to PATH) or via npm (global or local in the Wake project)
|
|
186
|
+
- On Windows, separate commands are exposed as `wake-storefront` and `wake-tailwind` instead of names containing `:`
|
|
187
|
+
|
|
188
|
+
## License
|
|
189
|
+
|
|
190
|
+
MIT
|
package/bin/wake.js
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const { spawn } = require('child_process');
|
|
6
|
+
|
|
7
|
+
const cwd = process.cwd();
|
|
8
|
+
|
|
9
|
+
function exitWithError(message) {
|
|
10
|
+
console.error(message);
|
|
11
|
+
process.exit(1);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function parseJsonFile(filePath, fileLabel) {
|
|
15
|
+
try {
|
|
16
|
+
return JSON.parse(fs.readFileSync(filePath, 'utf8').replace(/^\uFEFF/, ''));
|
|
17
|
+
} catch (error) {
|
|
18
|
+
exitWithError(`Erro: ${fileLabel} inválido.`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function getToken() {
|
|
23
|
+
const settingsPath = path.join(cwd, 'Configs', 'settings.json');
|
|
24
|
+
|
|
25
|
+
if (!fs.existsSync(settingsPath)) {
|
|
26
|
+
exitWithError('Erro: Configs/settings.json não encontrado. Execute dentro de um projeto Wake.');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const settings = parseJsonFile(settingsPath, 'Configs/settings.json');
|
|
30
|
+
const token = settings.access_token;
|
|
31
|
+
|
|
32
|
+
if (!token) {
|
|
33
|
+
exitWithError('Erro: access_token não encontrado no settings.json.');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return token;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function getInputFiles() {
|
|
40
|
+
const cssDir = path.join(cwd, 'Assets', 'CSS');
|
|
41
|
+
|
|
42
|
+
if (!fs.existsSync(cssDir)) {
|
|
43
|
+
exitWithError('Erro: pasta Assets/CSS não encontrada.');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const inputFiles = fs.readdirSync(cssDir, { withFileTypes: true })
|
|
47
|
+
.filter(
|
|
48
|
+
entry => entry.isFile() && entry.name.startsWith('input') && entry.name.endsWith('.css')
|
|
49
|
+
)
|
|
50
|
+
.map(entry => entry.name);
|
|
51
|
+
|
|
52
|
+
if (inputFiles.length === 0) {
|
|
53
|
+
exitWithError('Erro: nenhum arquivo input*.css encontrado em Assets/CSS.');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return inputFiles;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function spawnCommand(command, args) {
|
|
60
|
+
spawn(command, args, {
|
|
61
|
+
stdio: 'inherit',
|
|
62
|
+
cwd,
|
|
63
|
+
shell: true,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function hasLocalTailwindBinary() {
|
|
68
|
+
const localBinNames = process.platform === 'win32'
|
|
69
|
+
? ['tailwindcss.cmd', 'tailwindcss']
|
|
70
|
+
: ['tailwindcss'];
|
|
71
|
+
|
|
72
|
+
return localBinNames.some(binName =>
|
|
73
|
+
fs.existsSync(path.join(cwd, 'node_modules', '.bin', binName))
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function getTailwindCommand() {
|
|
78
|
+
if (hasLocalTailwindBinary()) {
|
|
79
|
+
return {
|
|
80
|
+
command: 'npm',
|
|
81
|
+
argsPrefix: ['exec', 'tailwindcss', '--'],
|
|
82
|
+
sourceLabel: 'npm local',
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return {
|
|
87
|
+
command: 'tailwindcss',
|
|
88
|
+
argsPrefix: [],
|
|
89
|
+
sourceLabel: 'PATH global',
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function runStorefront() {
|
|
94
|
+
const token = getToken();
|
|
95
|
+
|
|
96
|
+
console.log(`Token carregado: ${token.slice(0, 10)}...`);
|
|
97
|
+
console.log('Iniciando fbits.storefront...');
|
|
98
|
+
|
|
99
|
+
spawnCommand('fbits.storefront', ['--token', token]);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function runTailwind() {
|
|
103
|
+
const inputFiles = getInputFiles();
|
|
104
|
+
const tailwind = getTailwindCommand();
|
|
105
|
+
|
|
106
|
+
console.log(`Arquivos CSS encontrados: ${inputFiles.join(', ')}\n`);
|
|
107
|
+
console.log(`Usando Tailwind via ${tailwind.sourceLabel}.`);
|
|
108
|
+
|
|
109
|
+
for (const inputFile of inputFiles) {
|
|
110
|
+
const outputFile = inputFile.replace(/^input/, 'output');
|
|
111
|
+
const inputPath = `./Assets/CSS/${inputFile}`;
|
|
112
|
+
const outputPath = `./Assets/CSS/${outputFile}`;
|
|
113
|
+
|
|
114
|
+
console.log(`Iniciando Tailwind: ${inputFile} -> ${outputFile}`);
|
|
115
|
+
spawnCommand(tailwind.command, [
|
|
116
|
+
...tailwind.argsPrefix,
|
|
117
|
+
'-i',
|
|
118
|
+
inputPath,
|
|
119
|
+
'-o',
|
|
120
|
+
outputPath,
|
|
121
|
+
'--watch',
|
|
122
|
+
]);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function printUsage() {
|
|
127
|
+
console.log('Uso:');
|
|
128
|
+
console.log(' wake');
|
|
129
|
+
console.log(' wake storefront');
|
|
130
|
+
console.log(' wake tailwind');
|
|
131
|
+
console.log(' wake-storefront');
|
|
132
|
+
console.log(' wake-tailwind');
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function runCli(mode) {
|
|
136
|
+
switch (mode) {
|
|
137
|
+
case 'all':
|
|
138
|
+
runStorefront();
|
|
139
|
+
runTailwind();
|
|
140
|
+
break;
|
|
141
|
+
case 'storefront':
|
|
142
|
+
runStorefront();
|
|
143
|
+
break;
|
|
144
|
+
case 'tailwind':
|
|
145
|
+
runTailwind();
|
|
146
|
+
break;
|
|
147
|
+
default:
|
|
148
|
+
printUsage();
|
|
149
|
+
process.exit(1);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function isCliEntrypoint() {
|
|
154
|
+
const mainFilename = require.main && require.main.filename;
|
|
155
|
+
|
|
156
|
+
if (!mainFilename) {
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const allowedEntrypoints = [
|
|
161
|
+
__filename,
|
|
162
|
+
path.join(__dirname, 'wake-storefront.js'),
|
|
163
|
+
path.join(__dirname, 'wake-tailwind.js'),
|
|
164
|
+
];
|
|
165
|
+
|
|
166
|
+
return allowedEntrypoints.some(entrypoint =>
|
|
167
|
+
path.resolve(mainFilename) === path.resolve(entrypoint)
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (isCliEntrypoint()) {
|
|
172
|
+
const mode = process.env.WAKE_MODE || process.argv[2] || 'all';
|
|
173
|
+
runCli(mode);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
module.exports = {
|
|
177
|
+
runCli,
|
|
178
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "wake-runner",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "CLI to start Wake storefront projects",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"wake",
|
|
7
|
+
"cli",
|
|
8
|
+
"storefront",
|
|
9
|
+
"fbits",
|
|
10
|
+
"tailwindcss",
|
|
11
|
+
"automation"
|
|
12
|
+
],
|
|
13
|
+
"author": "Kelvin Simons",
|
|
14
|
+
"bin": {
|
|
15
|
+
"wake": "bin/wake.js",
|
|
16
|
+
"wake-storefront": "bin/wake-storefront.js",
|
|
17
|
+
"wake-tailwind": "bin/wake-tailwind.js"
|
|
18
|
+
},
|
|
19
|
+
"license": "MIT"
|
|
20
|
+
}
|