jac-client 0.2.8__py3-none-any.whl → 0.2.11__py3-none-any.whl
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.
- jac_client/examples/all-in-one/button.jac +4 -3
- jac_client/examples/all-in-one/components/CategoryFilter.jac +36 -24
- jac_client/examples/all-in-one/components/Header.jac +12 -8
- jac_client/examples/all-in-one/components/ProfitOverview.jac +49 -35
- jac_client/examples/all-in-one/components/Summary.jac +59 -36
- jac_client/examples/all-in-one/components/TransactionForm.jac +142 -112
- jac_client/examples/all-in-one/components/TransactionItem.jac +37 -30
- jac_client/examples/all-in-one/components/TransactionList.jac +33 -26
- jac_client/examples/all-in-one/components/button.jac +4 -3
- jac_client/examples/all-in-one/components/navigation.jac +111 -117
- jac_client/examples/all-in-one/constants/categories.jac +23 -24
- jac_client/examples/all-in-one/constants/clients.jac +7 -8
- jac_client/examples/all-in-one/context/BudgetContext.jac +9 -6
- jac_client/examples/all-in-one/hooks/useBudget.jac +18 -12
- jac_client/examples/all-in-one/hooks/useLocalStorage.jac +14 -13
- jac_client/examples/all-in-one/main.jac +542 -0
- jac_client/examples/all-in-one/pages/BudgetPlanner.jac +26 -12
- jac_client/examples/all-in-one/pages/FeaturesTest.jac +43 -12
- jac_client/examples/all-in-one/pages/LandingPage.jac +113 -90
- jac_client/examples/all-in-one/pages/budget_planner_ui.cl.jac +65 -0
- jac_client/examples/all-in-one/pages/features_test_ui.cl.jac +675 -0
- jac_client/examples/all-in-one/pages/loginPage.jac +114 -119
- jac_client/examples/all-in-one/pages/nestedDemo.jac +44 -51
- jac_client/examples/all-in-one/pages/notFound.jac +15 -21
- jac_client/examples/all-in-one/pages/signupPage.jac +113 -119
- jac_client/examples/all-in-one/utils/formatters.jac +5 -8
- jac_client/examples/asset-serving/css-with-image/main.jac +92 -0
- jac_client/examples/asset-serving/image-asset/main.jac +56 -0
- jac_client/examples/asset-serving/import-alias/main.jac +109 -0
- jac_client/examples/basic/main.jac +23 -0
- jac_client/examples/basic-auth/main.jac +363 -0
- jac_client/examples/basic-auth-with-router/main.jac +451 -0
- jac_client/examples/basic-full-stack/main.jac +362 -0
- jac_client/examples/css-styling/js-styling/main.jac +63 -0
- jac_client/examples/css-styling/material-ui/main.jac +122 -0
- jac_client/examples/css-styling/pure-css/main.jac +55 -0
- jac_client/examples/css-styling/sass-example/main.jac +55 -0
- jac_client/examples/css-styling/styled-components/main.jac +62 -0
- jac_client/examples/css-styling/tailwind-example/main.jac +74 -0
- jac_client/examples/full-stack-with-auth/main.jac +696 -0
- jac_client/examples/little-x/main.jac +681 -0
- jac_client/examples/little-x/src/submit-button.jac +15 -14
- jac_client/examples/nested-folders/nested-advance/main.jac +26 -0
- jac_client/examples/nested-folders/nested-advance/src/ButtonRoot.jac +4 -6
- jac_client/examples/nested-folders/nested-advance/src/level1/ButtonSecondL.jac +9 -13
- jac_client/examples/nested-folders/nested-advance/src/level1/Card.jac +29 -32
- jac_client/examples/nested-folders/nested-advance/src/level1/level2/ButtonThirdL.jac +12 -18
- jac_client/examples/nested-folders/nested-basic/{src/app.jac → main.jac} +7 -5
- jac_client/examples/nested-folders/nested-basic/src/button.jac +4 -3
- jac_client/examples/nested-folders/nested-basic/src/components/button.jac +4 -3
- jac_client/examples/ts-support/main.jac +35 -0
- jac_client/examples/with-router/main.jac +286 -0
- jac_client/plugin/cli.jac +491 -411
- jac_client/plugin/client.jac +25 -0
- jac_client/plugin/client_runtime.cl.jac +10 -4
- jac_client/plugin/impl/client.impl.jac +96 -55
- jac_client/plugin/impl/client_runtime.impl.jac +155 -1
- jac_client/plugin/plugin_config.jac +211 -29
- jac_client/plugin/src/__init__.jac +0 -2
- jac_client/plugin/src/compiler.jac +0 -1
- jac_client/plugin/src/config_loader.jac +1 -0
- jac_client/plugin/src/desktop_config.jac +31 -0
- jac_client/plugin/src/impl/compiler.impl.jac +49 -17
- jac_client/plugin/src/impl/config_loader.impl.jac +8 -0
- jac_client/plugin/src/impl/desktop_config.impl.jac +191 -0
- jac_client/plugin/src/impl/jac_to_js.impl.jac +5 -1
- jac_client/plugin/src/impl/package_installer.impl.jac +20 -20
- jac_client/plugin/src/impl/vite_bundler.impl.jac +191 -64
- jac_client/plugin/src/targets/desktop/sidecar/main.py +144 -0
- jac_client/plugin/src/targets/desktop_target.jac +37 -0
- jac_client/plugin/src/targets/impl/desktop_target.impl.jac +2347 -0
- jac_client/plugin/src/targets/impl/registry.impl.jac +64 -0
- jac_client/plugin/src/targets/impl/web_target.impl.jac +157 -0
- jac_client/plugin/src/targets/register.jac +21 -0
- jac_client/plugin/src/targets/registry.jac +87 -0
- jac_client/plugin/src/targets/web_target.jac +35 -0
- jac_client/plugin/src/vite_bundler.jac +6 -0
- jac_client/plugin/utils/__init__.jac +3 -0
- jac_client/plugin/utils/bun_installer.jac +16 -0
- jac_client/plugin/utils/impl/bun_installer.impl.jac +99 -0
- jac_client/templates/client.jacpack +72 -0
- jac_client/templates/fullstack.jacpack +61 -0
- jac_client/tests/conftest.py +103 -47
- jac_client/tests/fixtures/spawn_test/app.jac +49 -52
- jac_client/tests/fixtures/with-ts/app.jac +27 -27
- jac_client/tests/test_cli.py +182 -71
- jac_client/tests/test_e2e.py +232 -0
- jac_client/tests/test_helpers.py +58 -0
- jac_client/tests/test_it.py +91 -135
- jac_client/tests/test_it_desktop.py +891 -0
- {jac_client-0.2.8.dist-info → jac_client-0.2.11.dist-info}/METADATA +6 -6
- jac_client-0.2.11.dist-info/RECORD +113 -0
- {jac_client-0.2.8.dist-info → jac_client-0.2.11.dist-info}/WHEEL +1 -1
- jac_client/examples/all-in-one/app.jac +0 -573
- jac_client/examples/all-in-one/pages/BudgetPlanner.cl.jac +0 -70
- jac_client/examples/all-in-one/pages/FeaturesTest.cl.jac +0 -552
- jac_client/examples/asset-serving/css-with-image/src/app.jac +0 -88
- jac_client/examples/asset-serving/image-asset/src/app.jac +0 -55
- jac_client/examples/asset-serving/import-alias/src/app.jac +0 -111
- jac_client/examples/basic/src/app.jac +0 -21
- jac_client/examples/basic-auth/src/app.jac +0 -371
- jac_client/examples/basic-auth-with-router/src/app.jac +0 -464
- jac_client/examples/basic-full-stack/src/app.jac +0 -359
- jac_client/examples/css-styling/js-styling/src/app.jac +0 -84
- jac_client/examples/css-styling/material-ui/src/app.jac +0 -122
- jac_client/examples/css-styling/pure-css/src/app.jac +0 -64
- jac_client/examples/css-styling/sass-example/src/app.jac +0 -64
- jac_client/examples/css-styling/styled-components/src/app.jac +0 -71
- jac_client/examples/css-styling/tailwind-example/src/app.jac +0 -63
- jac_client/examples/full-stack-with-auth/src/app.jac +0 -722
- jac_client/examples/little-x/src/app.jac +0 -719
- jac_client/examples/nested-folders/nested-advance/src/app.jac +0 -35
- jac_client/examples/ts-support/src/app.jac +0 -35
- jac_client/examples/with-router/src/app.jac +0 -323
- jac_client/plugin/src/babel_processor.jac +0 -18
- jac_client/plugin/src/impl/babel_processor.impl.jac +0 -89
- jac_client-0.2.8.dist-info/RECORD +0 -97
- {jac_client-0.2.8.dist-info → jac_client-0.2.11.dist-info}/entry_points.txt +0 -0
- {jac_client-0.2.8.dist-info → jac_client-0.2.11.dist-info}/top_level.txt +0 -0
jac_client/tests/test_cli.py
CHANGED
|
@@ -7,7 +7,7 @@ from subprocess import PIPE, Popen, run
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
def test_create_jac_app() -> None:
|
|
10
|
-
"""Test jac create --
|
|
10
|
+
"""Test jac create --use client command."""
|
|
11
11
|
test_project_name = "test-jac-app"
|
|
12
12
|
|
|
13
13
|
# Create a temporary directory for testing
|
|
@@ -17,9 +17,9 @@ def test_create_jac_app() -> None:
|
|
|
17
17
|
# Change to temp directory
|
|
18
18
|
os.chdir(temp_dir)
|
|
19
19
|
|
|
20
|
-
# Run jac create --
|
|
20
|
+
# Run jac create --use client command
|
|
21
21
|
process = Popen(
|
|
22
|
-
["jac", "create", "--
|
|
22
|
+
["jac", "create", "--use", "client", test_project_name],
|
|
23
23
|
stdin=PIPE,
|
|
24
24
|
stdout=PIPE,
|
|
25
25
|
stderr=PIPE,
|
|
@@ -30,7 +30,11 @@ def test_create_jac_app() -> None:
|
|
|
30
30
|
|
|
31
31
|
# Check that command succeeded
|
|
32
32
|
assert result_code == 0
|
|
33
|
-
|
|
33
|
+
# Check for success message (handles both old and new console formats)
|
|
34
|
+
assert (
|
|
35
|
+
f"Project '{test_project_name}' created successfully!" in stdout
|
|
36
|
+
or f"Project '{test_project_name}' created" in stdout
|
|
37
|
+
)
|
|
34
38
|
|
|
35
39
|
# Verify project directory was created
|
|
36
40
|
project_path = os.path.join(temp_dir, test_project_name)
|
|
@@ -104,24 +108,29 @@ def test_create_jac_app() -> None:
|
|
|
104
108
|
|
|
105
109
|
|
|
106
110
|
def test_create_jac_app_invalid_name() -> None:
|
|
107
|
-
"""Test jac create --
|
|
111
|
+
"""Test jac create --use client command with project names containing spaces.
|
|
112
|
+
|
|
113
|
+
Note: The current implementation allows names with spaces. This test
|
|
114
|
+
verifies that such projects are created successfully.
|
|
115
|
+
"""
|
|
108
116
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
109
117
|
original_cwd = os.getcwd()
|
|
110
118
|
try:
|
|
111
119
|
os.chdir(temp_dir)
|
|
112
120
|
|
|
113
|
-
# Test with
|
|
121
|
+
# Test with name containing spaces (currently allowed)
|
|
114
122
|
result = run(
|
|
115
|
-
["jac", "create", "--
|
|
123
|
+
["jac", "create", "--use", "client", "--skip", "name with spaces"],
|
|
116
124
|
capture_output=True,
|
|
117
125
|
text=True,
|
|
118
126
|
)
|
|
119
127
|
|
|
120
|
-
#
|
|
121
|
-
assert result.returncode
|
|
128
|
+
# Currently succeeds - names with spaces are allowed
|
|
129
|
+
assert result.returncode == 0
|
|
130
|
+
# Check for success message (handles both old and new console formats)
|
|
122
131
|
assert (
|
|
123
|
-
"Project name
|
|
124
|
-
in result.
|
|
132
|
+
"Project 'name with spaces' created successfully!" in result.stdout
|
|
133
|
+
or "Project 'name with spaces' created" in result.stdout
|
|
125
134
|
)
|
|
126
135
|
|
|
127
136
|
finally:
|
|
@@ -129,7 +138,7 @@ def test_create_jac_app_invalid_name() -> None:
|
|
|
129
138
|
|
|
130
139
|
|
|
131
140
|
def test_create_jac_app_existing_directory() -> None:
|
|
132
|
-
"""Test jac create --
|
|
141
|
+
"""Test jac create --use client command when directory already exists."""
|
|
133
142
|
test_project_name = "existing-test-app"
|
|
134
143
|
|
|
135
144
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
@@ -142,7 +151,7 @@ def test_create_jac_app_existing_directory() -> None:
|
|
|
142
151
|
|
|
143
152
|
# Try to create app with same name
|
|
144
153
|
process = Popen(
|
|
145
|
-
["jac", "create", "--
|
|
154
|
+
["jac", "create", "--use", "client", test_project_name],
|
|
146
155
|
stdin=PIPE,
|
|
147
156
|
stdout=PIPE,
|
|
148
157
|
stderr=PIPE,
|
|
@@ -160,7 +169,7 @@ def test_create_jac_app_existing_directory() -> None:
|
|
|
160
169
|
|
|
161
170
|
|
|
162
171
|
def test_create_jac_app_with_button_component() -> None:
|
|
163
|
-
"""Test jac create --
|
|
172
|
+
"""Test jac create --use client command creates Button.cl.jac component."""
|
|
164
173
|
test_project_name = "test-jac-app-component"
|
|
165
174
|
|
|
166
175
|
# Create a temporary directory for testing
|
|
@@ -170,9 +179,9 @@ def test_create_jac_app_with_button_component() -> None:
|
|
|
170
179
|
# Change to temp directory
|
|
171
180
|
os.chdir(temp_dir)
|
|
172
181
|
|
|
173
|
-
# Run jac create --
|
|
182
|
+
# Run jac create --use client command
|
|
174
183
|
process = Popen(
|
|
175
|
-
["jac", "create", "--
|
|
184
|
+
["jac", "create", "--use", "client", test_project_name],
|
|
176
185
|
stdin=PIPE,
|
|
177
186
|
stdout=PIPE,
|
|
178
187
|
stderr=PIPE,
|
|
@@ -183,7 +192,11 @@ def test_create_jac_app_with_button_component() -> None:
|
|
|
183
192
|
|
|
184
193
|
# Check that command succeeded
|
|
185
194
|
assert result_code == 0
|
|
186
|
-
|
|
195
|
+
# Check for success message (handles both old and new console formats)
|
|
196
|
+
assert (
|
|
197
|
+
f"Project '{test_project_name}' created successfully!" in stdout
|
|
198
|
+
or f"Project '{test_project_name}' created" in stdout
|
|
199
|
+
)
|
|
187
200
|
|
|
188
201
|
# Verify project directory was created
|
|
189
202
|
project_path = os.path.join(temp_dir, test_project_name)
|
|
@@ -259,7 +272,7 @@ def test_create_jac_app_with_button_component() -> None:
|
|
|
259
272
|
|
|
260
273
|
|
|
261
274
|
def test_create_jac_app_with_skip_flag() -> None:
|
|
262
|
-
"""Test jac create --
|
|
275
|
+
"""Test jac create --use client --skip command skips package installation."""
|
|
263
276
|
test_project_name = "test-jac-app-skip"
|
|
264
277
|
|
|
265
278
|
# Create a temporary directory for testing
|
|
@@ -269,9 +282,9 @@ def test_create_jac_app_with_skip_flag() -> None:
|
|
|
269
282
|
# Change to temp directory
|
|
270
283
|
os.chdir(temp_dir)
|
|
271
284
|
|
|
272
|
-
# Run jac create --
|
|
285
|
+
# Run jac create --use client --skip command
|
|
273
286
|
process = Popen(
|
|
274
|
-
["jac", "create", "--
|
|
287
|
+
["jac", "create", "--use", "client", "--skip", test_project_name],
|
|
275
288
|
stdin=PIPE,
|
|
276
289
|
stdout=PIPE,
|
|
277
290
|
stderr=PIPE,
|
|
@@ -282,7 +295,11 @@ def test_create_jac_app_with_skip_flag() -> None:
|
|
|
282
295
|
|
|
283
296
|
# Check that command succeeded
|
|
284
297
|
assert result_code == 0
|
|
285
|
-
|
|
298
|
+
# Check for success message (handles both old and new console formats)
|
|
299
|
+
assert (
|
|
300
|
+
f"Project '{test_project_name}' created successfully!" in stdout
|
|
301
|
+
or f"Project '{test_project_name}' created" in stdout
|
|
302
|
+
)
|
|
286
303
|
|
|
287
304
|
# Verify project directory was created
|
|
288
305
|
project_path = os.path.join(temp_dir, test_project_name)
|
|
@@ -303,7 +320,7 @@ def test_create_jac_app_with_skip_flag() -> None:
|
|
|
303
320
|
|
|
304
321
|
|
|
305
322
|
def test_create_jac_app_installs_default_packages() -> None:
|
|
306
|
-
"""Test jac create --
|
|
323
|
+
"""Test jac create --use client command attempts to install default packages."""
|
|
307
324
|
test_project_name = "test-jac-app-install"
|
|
308
325
|
|
|
309
326
|
# Create a temporary directory for testing
|
|
@@ -313,9 +330,9 @@ def test_create_jac_app_installs_default_packages() -> None:
|
|
|
313
330
|
# Change to temp directory
|
|
314
331
|
os.chdir(temp_dir)
|
|
315
332
|
|
|
316
|
-
# Run jac create --
|
|
333
|
+
# Run jac create --use client command
|
|
317
334
|
process = Popen(
|
|
318
|
-
["jac", "create", "--
|
|
335
|
+
["jac", "create", "--use", "client", test_project_name],
|
|
319
336
|
stdin=PIPE,
|
|
320
337
|
stdout=PIPE,
|
|
321
338
|
stderr=PIPE,
|
|
@@ -326,14 +343,19 @@ def test_create_jac_app_installs_default_packages() -> None:
|
|
|
326
343
|
|
|
327
344
|
# Check that command succeeded
|
|
328
345
|
assert result_code == 0
|
|
329
|
-
|
|
346
|
+
# Check for success message (handles both old and new console formats)
|
|
347
|
+
assert (
|
|
348
|
+
f"Project '{test_project_name}' created successfully!" in stdout
|
|
349
|
+
or f"Project '{test_project_name}' created" in stdout
|
|
350
|
+
)
|
|
330
351
|
|
|
331
352
|
# Verify project directory was created
|
|
332
353
|
project_path = os.path.join(temp_dir, test_project_name)
|
|
333
354
|
assert os.path.exists(project_path)
|
|
334
355
|
|
|
335
|
-
# Verify that
|
|
336
|
-
|
|
356
|
+
# Verify that package.json was generated - this confirms the setup worked
|
|
357
|
+
# Note: Package installation output may go to stderr or use rich formatting
|
|
358
|
+
# that doesn't capture cleanly in subprocess output
|
|
337
359
|
|
|
338
360
|
# Verify package.json was generated (even if npm install failed)
|
|
339
361
|
package_json_path = os.path.join(
|
|
@@ -423,13 +445,13 @@ entry-point = "app.jac"
|
|
|
423
445
|
|
|
424
446
|
|
|
425
447
|
def test_install_without_cl_flag() -> None:
|
|
426
|
-
"""Test add command without --
|
|
448
|
+
"""Test add command without --npm flag should skip silently when no jac.toml exists."""
|
|
427
449
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
428
450
|
original_cwd = os.getcwd()
|
|
429
451
|
try:
|
|
430
452
|
os.chdir(temp_dir)
|
|
431
453
|
|
|
432
|
-
# Run add command without --
|
|
454
|
+
# Run add command without --npm flag and without jac.toml
|
|
433
455
|
result = run(
|
|
434
456
|
["jac", "add", "lodash"],
|
|
435
457
|
capture_output=True,
|
|
@@ -447,7 +469,7 @@ def test_install_without_cl_flag() -> None:
|
|
|
447
469
|
|
|
448
470
|
|
|
449
471
|
def test_install_all_packages() -> None:
|
|
450
|
-
"""Test add --
|
|
472
|
+
"""Test add --npm command installs all packages from jac.toml."""
|
|
451
473
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
452
474
|
original_cwd = os.getcwd()
|
|
453
475
|
try:
|
|
@@ -456,24 +478,31 @@ def test_install_all_packages() -> None:
|
|
|
456
478
|
# Create jac.toml with some dependencies
|
|
457
479
|
_create_jac_toml(temp_dir, deps='lodash = "^4.17.21"')
|
|
458
480
|
|
|
459
|
-
# Run add --
|
|
481
|
+
# Run add --npm command without package name
|
|
460
482
|
result = run(
|
|
461
|
-
["jac", "add", "--
|
|
483
|
+
["jac", "add", "--npm"],
|
|
462
484
|
capture_output=True,
|
|
463
485
|
text=True,
|
|
464
486
|
)
|
|
465
487
|
|
|
466
488
|
# Should succeed
|
|
467
489
|
assert result.returncode == 0
|
|
468
|
-
|
|
469
|
-
assert
|
|
490
|
+
# Check for install messages (handles both old and new console formats)
|
|
491
|
+
assert (
|
|
492
|
+
"Installing all npm packages" in result.stdout
|
|
493
|
+
or "Installing all npm packages" in result.stdout.lower()
|
|
494
|
+
)
|
|
495
|
+
assert (
|
|
496
|
+
"Installed all npm packages successfully" in result.stdout
|
|
497
|
+
or "Installed all npm packages" in result.stdout
|
|
498
|
+
)
|
|
470
499
|
|
|
471
500
|
finally:
|
|
472
501
|
os.chdir(original_cwd)
|
|
473
502
|
|
|
474
503
|
|
|
475
504
|
def test_install_package_to_dependencies() -> None:
|
|
476
|
-
"""Test add --
|
|
505
|
+
"""Test add --npm command adds package to dependencies."""
|
|
477
506
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
478
507
|
original_cwd = os.getcwd()
|
|
479
508
|
try:
|
|
@@ -482,17 +511,25 @@ def test_install_package_to_dependencies() -> None:
|
|
|
482
511
|
# Create jac.toml
|
|
483
512
|
config_path = _create_jac_toml(temp_dir)
|
|
484
513
|
|
|
485
|
-
# Run add --
|
|
514
|
+
# Run add --npm command with package name
|
|
486
515
|
result = run(
|
|
487
|
-
["jac", "add", "--
|
|
516
|
+
["jac", "add", "--npm", "lodash"],
|
|
488
517
|
capture_output=True,
|
|
489
518
|
text=True,
|
|
490
519
|
)
|
|
491
520
|
|
|
492
521
|
# Should succeed
|
|
493
522
|
assert result.returncode == 0
|
|
494
|
-
|
|
495
|
-
assert
|
|
523
|
+
# Check for package add messages (handles both old and new console formats)
|
|
524
|
+
assert (
|
|
525
|
+
"Adding lodash (npm)" in result.stdout
|
|
526
|
+
or "lodash" in result.stdout.lower()
|
|
527
|
+
)
|
|
528
|
+
assert (
|
|
529
|
+
"Added 1 package(s) to [dependencies.npm]" in result.stdout
|
|
530
|
+
or "Updated jac.toml" in result.stdout
|
|
531
|
+
or "dependencies.npm" in result.stdout
|
|
532
|
+
)
|
|
496
533
|
|
|
497
534
|
# Verify package was added to jac.toml
|
|
498
535
|
with open(config_path, "rb") as f:
|
|
@@ -505,7 +542,7 @@ def test_install_package_to_dependencies() -> None:
|
|
|
505
542
|
|
|
506
543
|
|
|
507
544
|
def test_install_package_with_version() -> None:
|
|
508
|
-
"""Test add --
|
|
545
|
+
"""Test add --npm command with specific version."""
|
|
509
546
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
510
547
|
original_cwd = os.getcwd()
|
|
511
548
|
try:
|
|
@@ -514,17 +551,25 @@ def test_install_package_with_version() -> None:
|
|
|
514
551
|
# Create jac.toml
|
|
515
552
|
config_path = _create_jac_toml(temp_dir)
|
|
516
553
|
|
|
517
|
-
# Run add --
|
|
554
|
+
# Run add --npm command with package and version
|
|
518
555
|
result = run(
|
|
519
|
-
["jac", "add", "--
|
|
556
|
+
["jac", "add", "--npm", "lodash@^4.17.21"],
|
|
520
557
|
capture_output=True,
|
|
521
558
|
text=True,
|
|
522
559
|
)
|
|
523
560
|
|
|
524
561
|
# Should succeed
|
|
525
562
|
assert result.returncode == 0
|
|
526
|
-
|
|
527
|
-
assert
|
|
563
|
+
# Check for package add messages (handles both old and new console formats)
|
|
564
|
+
assert (
|
|
565
|
+
"Adding lodash (npm)" in result.stdout
|
|
566
|
+
or "lodash" in result.stdout.lower()
|
|
567
|
+
)
|
|
568
|
+
assert (
|
|
569
|
+
"Added 1 package(s) to [dependencies.npm]" in result.stdout
|
|
570
|
+
or "Updated jac.toml" in result.stdout
|
|
571
|
+
or "dependencies.npm" in result.stdout
|
|
572
|
+
)
|
|
528
573
|
|
|
529
574
|
# Verify package was added with correct version
|
|
530
575
|
with open(config_path, "rb") as f:
|
|
@@ -537,7 +582,7 @@ def test_install_package_with_version() -> None:
|
|
|
537
582
|
|
|
538
583
|
|
|
539
584
|
def test_install_package_to_devdependencies() -> None:
|
|
540
|
-
"""Test add --
|
|
585
|
+
"""Test add --npm -d command adds package to dev-dependencies."""
|
|
541
586
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
542
587
|
original_cwd = os.getcwd()
|
|
543
588
|
try:
|
|
@@ -546,9 +591,9 @@ def test_install_package_to_devdependencies() -> None:
|
|
|
546
591
|
# Create jac.toml
|
|
547
592
|
config_path = _create_jac_toml(temp_dir)
|
|
548
593
|
|
|
549
|
-
# Run add --
|
|
594
|
+
# Run add --npm -d command
|
|
550
595
|
run(
|
|
551
|
-
["jac", "add", "--
|
|
596
|
+
["jac", "add", "--npm", "-d", "@types/react"],
|
|
552
597
|
capture_output=True,
|
|
553
598
|
text=True,
|
|
554
599
|
)
|
|
@@ -568,15 +613,15 @@ def test_install_package_to_devdependencies() -> None:
|
|
|
568
613
|
|
|
569
614
|
|
|
570
615
|
def test_install_without_config_json() -> None:
|
|
571
|
-
"""Test add --
|
|
616
|
+
"""Test add --npm command when jac.toml doesn't exist."""
|
|
572
617
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
573
618
|
original_cwd = os.getcwd()
|
|
574
619
|
try:
|
|
575
620
|
os.chdir(temp_dir)
|
|
576
621
|
|
|
577
|
-
# Run add --
|
|
622
|
+
# Run add --npm command without jac.toml
|
|
578
623
|
result = run(
|
|
579
|
-
["jac", "add", "--
|
|
624
|
+
["jac", "add", "--npm", "lodash"],
|
|
580
625
|
capture_output=True,
|
|
581
626
|
text=True,
|
|
582
627
|
)
|
|
@@ -590,13 +635,13 @@ def test_install_without_config_json() -> None:
|
|
|
590
635
|
|
|
591
636
|
|
|
592
637
|
def test_uninstall_without_cl_flag() -> None:
|
|
593
|
-
"""Test remove command without --
|
|
638
|
+
"""Test remove command without --npm flag should fail when no jac.toml exists."""
|
|
594
639
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
595
640
|
original_cwd = os.getcwd()
|
|
596
641
|
try:
|
|
597
642
|
os.chdir(temp_dir)
|
|
598
643
|
|
|
599
|
-
# Run remove command without --
|
|
644
|
+
# Run remove command without --npm flag and without jac.toml
|
|
600
645
|
result = run(
|
|
601
646
|
["jac", "remove", "lodash"],
|
|
602
647
|
capture_output=True,
|
|
@@ -612,7 +657,7 @@ def test_uninstall_without_cl_flag() -> None:
|
|
|
612
657
|
|
|
613
658
|
|
|
614
659
|
def test_uninstall_without_package_name() -> None:
|
|
615
|
-
"""Test remove --
|
|
660
|
+
"""Test remove --npm command without package name should fail."""
|
|
616
661
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
617
662
|
original_cwd = os.getcwd()
|
|
618
663
|
try:
|
|
@@ -621,9 +666,9 @@ def test_uninstall_without_package_name() -> None:
|
|
|
621
666
|
# Create jac.toml
|
|
622
667
|
_create_jac_toml(temp_dir)
|
|
623
668
|
|
|
624
|
-
# Run remove --
|
|
669
|
+
# Run remove --npm command without package name
|
|
625
670
|
result = run(
|
|
626
|
-
["jac", "remove", "--
|
|
671
|
+
["jac", "remove", "--npm"],
|
|
627
672
|
capture_output=True,
|
|
628
673
|
text=True,
|
|
629
674
|
)
|
|
@@ -637,7 +682,7 @@ def test_uninstall_without_package_name() -> None:
|
|
|
637
682
|
|
|
638
683
|
|
|
639
684
|
def test_uninstall_package_from_dependencies() -> None:
|
|
640
|
-
"""Test remove --
|
|
685
|
+
"""Test remove --npm command removes package from dependencies."""
|
|
641
686
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
642
687
|
original_cwd = os.getcwd()
|
|
643
688
|
try:
|
|
@@ -646,9 +691,9 @@ def test_uninstall_package_from_dependencies() -> None:
|
|
|
646
691
|
# Create jac.toml with a package
|
|
647
692
|
config_path = _create_jac_toml(temp_dir, deps='lodash = "^4.17.21"')
|
|
648
693
|
|
|
649
|
-
# Run remove --
|
|
694
|
+
# Run remove --npm command
|
|
650
695
|
result = run(
|
|
651
|
-
["jac", "remove", "--
|
|
696
|
+
["jac", "remove", "--npm", "lodash"],
|
|
652
697
|
capture_output=True,
|
|
653
698
|
text=True,
|
|
654
699
|
)
|
|
@@ -671,7 +716,7 @@ def test_uninstall_package_from_dependencies() -> None:
|
|
|
671
716
|
|
|
672
717
|
|
|
673
718
|
def test_uninstall_package_from_devdependencies() -> None:
|
|
674
|
-
"""Test remove --
|
|
719
|
+
"""Test remove --npm -d command removes package from dev-dependencies."""
|
|
675
720
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
676
721
|
original_cwd = os.getcwd()
|
|
677
722
|
try:
|
|
@@ -682,9 +727,9 @@ def test_uninstall_package_from_devdependencies() -> None:
|
|
|
682
727
|
temp_dir, dev_deps='"@types/react" = "^18.0.0"'
|
|
683
728
|
)
|
|
684
729
|
|
|
685
|
-
# Run remove --
|
|
730
|
+
# Run remove --npm -d command
|
|
686
731
|
result = run(
|
|
687
|
-
["jac", "remove", "--
|
|
732
|
+
["jac", "remove", "--npm", "-d", "@types/react"],
|
|
688
733
|
capture_output=True,
|
|
689
734
|
text=True,
|
|
690
735
|
)
|
|
@@ -706,7 +751,7 @@ def test_uninstall_package_from_devdependencies() -> None:
|
|
|
706
751
|
|
|
707
752
|
|
|
708
753
|
def test_uninstall_nonexistent_package() -> None:
|
|
709
|
-
"""Test remove --
|
|
754
|
+
"""Test remove --npm command with non-existent package should fail."""
|
|
710
755
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
711
756
|
original_cwd = os.getcwd()
|
|
712
757
|
try:
|
|
@@ -715,9 +760,9 @@ def test_uninstall_nonexistent_package() -> None:
|
|
|
715
760
|
# Create jac.toml without the package
|
|
716
761
|
_create_jac_toml(temp_dir)
|
|
717
762
|
|
|
718
|
-
# Run remove --
|
|
763
|
+
# Run remove --npm command with non-existent package
|
|
719
764
|
result = run(
|
|
720
|
-
["jac", "remove", "--
|
|
765
|
+
["jac", "remove", "--npm", "nonexistent-package"],
|
|
721
766
|
capture_output=True,
|
|
722
767
|
text=True,
|
|
723
768
|
)
|
|
@@ -731,15 +776,15 @@ def test_uninstall_nonexistent_package() -> None:
|
|
|
731
776
|
|
|
732
777
|
|
|
733
778
|
def test_uninstall_without_config_toml() -> None:
|
|
734
|
-
"""Test remove --
|
|
779
|
+
"""Test remove --npm command when jac.toml doesn't exist."""
|
|
735
780
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
736
781
|
original_cwd = os.getcwd()
|
|
737
782
|
try:
|
|
738
783
|
os.chdir(temp_dir)
|
|
739
784
|
|
|
740
|
-
# Run remove --
|
|
785
|
+
# Run remove --npm command without jac.toml
|
|
741
786
|
result = run(
|
|
742
|
-
["jac", "remove", "--
|
|
787
|
+
["jac", "remove", "--npm", "lodash"],
|
|
743
788
|
capture_output=True,
|
|
744
789
|
text=True,
|
|
745
790
|
)
|
|
@@ -752,8 +797,74 @@ def test_uninstall_without_config_toml() -> None:
|
|
|
752
797
|
os.chdir(original_cwd)
|
|
753
798
|
|
|
754
799
|
|
|
800
|
+
def test_config_files_from_jac_toml() -> None:
|
|
801
|
+
"""Test that [plugins.client.configs] in jac.toml generates config files."""
|
|
802
|
+
with tempfile.TemporaryDirectory() as temp_dir:
|
|
803
|
+
original_cwd = os.getcwd()
|
|
804
|
+
try:
|
|
805
|
+
os.chdir(temp_dir)
|
|
806
|
+
|
|
807
|
+
# Create jac.toml with postcss and tailwind configs
|
|
808
|
+
toml_content = """[project]
|
|
809
|
+
name = "test-configs"
|
|
810
|
+
version = "1.0.0"
|
|
811
|
+
description = "Test project"
|
|
812
|
+
entry-point = "main.jac"
|
|
813
|
+
|
|
814
|
+
[plugins.client.configs.postcss]
|
|
815
|
+
plugins = ["tailwindcss", "autoprefixer"]
|
|
816
|
+
|
|
817
|
+
[plugins.client.configs.tailwind]
|
|
818
|
+
content = ["./**/*.jac", "./.jac/client/**/*.{js,jsx}"]
|
|
819
|
+
plugins = []
|
|
820
|
+
|
|
821
|
+
[plugins.client.configs.tailwind.theme.extend]
|
|
822
|
+
colors = { primary = "#3490dc" }
|
|
823
|
+
"""
|
|
824
|
+
config_path = os.path.join(temp_dir, "jac.toml")
|
|
825
|
+
with open(config_path, "w") as f:
|
|
826
|
+
f.write(toml_content)
|
|
827
|
+
|
|
828
|
+
# Import and use ViteBundler to generate config files
|
|
829
|
+
from pathlib import Path
|
|
830
|
+
|
|
831
|
+
from jac_client.plugin.src.vite_bundler import ViteBundler
|
|
832
|
+
|
|
833
|
+
bundler = ViteBundler(Path(temp_dir))
|
|
834
|
+
created_files = bundler.create_config_files()
|
|
835
|
+
|
|
836
|
+
# Verify two config files were created
|
|
837
|
+
assert len(created_files) == 2
|
|
838
|
+
|
|
839
|
+
# Verify postcss.config.js was created with correct content
|
|
840
|
+
configs_dir = os.path.join(temp_dir, ".jac", "client", "configs")
|
|
841
|
+
postcss_config = os.path.join(configs_dir, "postcss.config.js")
|
|
842
|
+
assert os.path.exists(postcss_config)
|
|
843
|
+
|
|
844
|
+
with open(postcss_config) as f:
|
|
845
|
+
postcss_content = f.read()
|
|
846
|
+
|
|
847
|
+
assert "module.exports" in postcss_content
|
|
848
|
+
assert "tailwindcss" in postcss_content
|
|
849
|
+
assert "autoprefixer" in postcss_content
|
|
850
|
+
|
|
851
|
+
# Verify tailwind.config.js was created with correct content
|
|
852
|
+
tailwind_config = os.path.join(configs_dir, "tailwind.config.js")
|
|
853
|
+
assert os.path.exists(tailwind_config)
|
|
854
|
+
|
|
855
|
+
with open(tailwind_config) as f:
|
|
856
|
+
tailwind_content = f.read()
|
|
857
|
+
|
|
858
|
+
assert "module.exports" in tailwind_content
|
|
859
|
+
assert "./**/*.jac" in tailwind_content
|
|
860
|
+
assert "#3490dc" in tailwind_content
|
|
861
|
+
|
|
862
|
+
finally:
|
|
863
|
+
os.chdir(original_cwd)
|
|
864
|
+
|
|
865
|
+
|
|
755
866
|
def test_create_cl_and_run_no_root_files() -> None:
|
|
756
|
-
"""Test that jac create --
|
|
867
|
+
"""Test that jac create --use client + jac run doesn't create files outside .jac/ directory."""
|
|
757
868
|
test_project_name = "test-cl-no-root-files"
|
|
758
869
|
|
|
759
870
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
@@ -761,16 +872,16 @@ def test_create_cl_and_run_no_root_files() -> None:
|
|
|
761
872
|
try:
|
|
762
873
|
os.chdir(temp_dir)
|
|
763
874
|
|
|
764
|
-
# Run jac create --
|
|
875
|
+
# Run jac create --use client command
|
|
765
876
|
process = Popen(
|
|
766
|
-
["jac", "create", "--
|
|
877
|
+
["jac", "create", "--use", "client", test_project_name],
|
|
767
878
|
stdin=PIPE,
|
|
768
879
|
stdout=PIPE,
|
|
769
880
|
stderr=PIPE,
|
|
770
881
|
text=True,
|
|
771
882
|
)
|
|
772
883
|
stdout, stderr = process.communicate()
|
|
773
|
-
assert process.returncode == 0, f"jac create --
|
|
884
|
+
assert process.returncode == 0, f"jac create --use client failed: {stderr}"
|
|
774
885
|
|
|
775
886
|
project_path = os.path.join(temp_dir, test_project_name)
|
|
776
887
|
|