jac-client 0.2.7__py3-none-any.whl → 0.2.9__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/{src/app.jac → main.jac} +5 -5
- jac_client/examples/all-in-one/{src/pages → pages}/BudgetPlanner.jac +8 -1
- jac_client/examples/all-in-one/{src/pages → pages}/FeaturesTest.jac +16 -1
- jac_client/examples/all-in-one/{src/pages/FeaturesTest.cl.jac → pages/features_test_ui.cl.jac} +11 -0
- jac_client/examples/all-in-one/{src/pages → pages}/nestedDemo.jac +1 -1
- jac_client/examples/all-in-one/{src/pages → pages}/notFound.jac +2 -7
- jac_client/plugin/cli.jac +162 -430
- jac_client/plugin/client.jac +30 -12
- jac_client/plugin/client_runtime.cl.jac +19 -15
- jac_client/plugin/impl/client.impl.jac +107 -69
- jac_client/plugin/impl/client_runtime.impl.jac +181 -9
- jac_client/plugin/plugin_config.jac +243 -15
- jac_client/plugin/src/config_loader.jac +1 -0
- jac_client/plugin/src/impl/compiler.impl.jac +2 -4
- jac_client/plugin/src/impl/config_loader.impl.jac +8 -0
- jac_client/plugin/src/impl/vite_bundler.impl.jac +241 -11
- jac_client/plugin/src/vite_bundler.jac +14 -1
- jac_client/plugin/utils/__init__.jac +1 -0
- jac_client/plugin/utils/impl/node_installer.impl.jac +249 -0
- jac_client/plugin/utils/node_installer.jac +41 -0
- jac_client/templates/client.jacpack +72 -0
- jac_client/templates/fullstack.jacpack +61 -0
- jac_client/tests/conftest.py +48 -7
- jac_client/tests/test_cli.py +189 -73
- jac_client/tests/test_e2e.py +232 -0
- jac_client/tests/test_helpers.py +65 -0
- jac_client/tests/test_it.py +97 -137
- {jac_client-0.2.7.dist-info → jac_client-0.2.9.dist-info}/METADATA +4 -4
- jac_client-0.2.9.dist-info/RECORD +104 -0
- {jac_client-0.2.7.dist-info → jac_client-0.2.9.dist-info}/WHEEL +1 -1
- jac_client-0.2.7.dist-info/RECORD +0 -97
- /jac_client/examples/all-in-one/{src/button.jac → button.jac} +0 -0
- /jac_client/examples/all-in-one/{src/components → components}/CategoryFilter.jac +0 -0
- /jac_client/examples/all-in-one/{src/components → components}/Header.jac +0 -0
- /jac_client/examples/all-in-one/{src/components → components}/ProfitOverview.jac +0 -0
- /jac_client/examples/all-in-one/{src/components → components}/Summary.jac +0 -0
- /jac_client/examples/all-in-one/{src/components → components}/TransactionForm.jac +0 -0
- /jac_client/examples/all-in-one/{src/components → components}/TransactionItem.jac +0 -0
- /jac_client/examples/all-in-one/{src/components → components}/TransactionList.jac +0 -0
- /jac_client/examples/all-in-one/{src/components → components}/button.jac +0 -0
- /jac_client/examples/all-in-one/{src/components → components}/navigation.jac +0 -0
- /jac_client/examples/all-in-one/{src/constants → constants}/categories.jac +0 -0
- /jac_client/examples/all-in-one/{src/constants → constants}/clients.jac +0 -0
- /jac_client/examples/all-in-one/{src/context → context}/BudgetContext.jac +0 -0
- /jac_client/examples/all-in-one/{src/hooks → hooks}/useBudget.jac +0 -0
- /jac_client/examples/all-in-one/{src/hooks → hooks}/useLocalStorage.jac +0 -0
- /jac_client/examples/all-in-one/{src/pages → pages}/LandingPage.jac +0 -0
- /jac_client/examples/all-in-one/{src/pages/BudgetPlanner.cl.jac → pages/budget_planner_ui.cl.jac} +0 -0
- /jac_client/examples/all-in-one/{src/pages → pages}/loginPage.jac +0 -0
- /jac_client/examples/all-in-one/{src/pages → pages}/signupPage.jac +0 -0
- /jac_client/examples/all-in-one/{src/utils → utils}/formatters.jac +0 -0
- /jac_client/examples/asset-serving/css-with-image/{src/app.jac → main.jac} +0 -0
- /jac_client/examples/asset-serving/image-asset/{src/app.jac → main.jac} +0 -0
- /jac_client/examples/asset-serving/import-alias/{src/app.jac → main.jac} +0 -0
- /jac_client/examples/basic/{src/app.jac → main.jac} +0 -0
- /jac_client/examples/basic-auth/{src/app.jac → main.jac} +0 -0
- /jac_client/examples/basic-auth-with-router/{src/app.jac → main.jac} +0 -0
- /jac_client/examples/basic-full-stack/{src/app.jac → main.jac} +0 -0
- /jac_client/examples/css-styling/js-styling/{src/app.jac → main.jac} +0 -0
- /jac_client/examples/css-styling/material-ui/{src/app.jac → main.jac} +0 -0
- /jac_client/examples/css-styling/pure-css/{src/app.jac → main.jac} +0 -0
- /jac_client/examples/css-styling/sass-example/{src/app.jac → main.jac} +0 -0
- /jac_client/examples/css-styling/styled-components/{src/app.jac → main.jac} +0 -0
- /jac_client/examples/css-styling/tailwind-example/{src/app.jac → main.jac} +0 -0
- /jac_client/examples/full-stack-with-auth/{src/app.jac → main.jac} +0 -0
- /jac_client/examples/little-x/{src/app.jac → main.jac} +0 -0
- /jac_client/examples/nested-folders/nested-advance/{src/app.jac → main.jac} +0 -0
- /jac_client/examples/nested-folders/nested-basic/{src/app.jac → main.jac} +0 -0
- /jac_client/examples/ts-support/{src/app.jac → main.jac} +0 -0
- /jac_client/examples/with-router/{src/app.jac → main.jac} +0 -0
- {jac_client-0.2.7.dist-info → jac_client-0.2.9.dist-info}/entry_points.txt +0 -0
- {jac_client-0.2.7.dist-info → jac_client-0.2.9.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,22 @@ 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
356
|
# Verify that installation was attempted (message should be in output)
|
|
336
|
-
|
|
357
|
+
# Handles both old and new console formats
|
|
358
|
+
assert (
|
|
359
|
+
"Installing default npm packages" in stdout
|
|
360
|
+
or "Installing npm packages" in stdout
|
|
361
|
+
)
|
|
337
362
|
|
|
338
363
|
# Verify package.json was generated (even if npm install failed)
|
|
339
364
|
package_json_path = os.path.join(
|
|
@@ -423,29 +448,31 @@ entry-point = "app.jac"
|
|
|
423
448
|
|
|
424
449
|
|
|
425
450
|
def test_install_without_cl_flag() -> None:
|
|
426
|
-
"""Test add command without --
|
|
451
|
+
"""Test add command without --npm flag should skip silently when no jac.toml exists."""
|
|
427
452
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
428
453
|
original_cwd = os.getcwd()
|
|
429
454
|
try:
|
|
430
455
|
os.chdir(temp_dir)
|
|
431
456
|
|
|
432
|
-
# Run add command without --
|
|
457
|
+
# Run add command without --npm flag and without jac.toml
|
|
433
458
|
result = run(
|
|
434
459
|
["jac", "add", "lodash"],
|
|
435
460
|
capture_output=True,
|
|
436
461
|
text=True,
|
|
437
462
|
)
|
|
438
463
|
|
|
439
|
-
# Should
|
|
440
|
-
assert result.returncode
|
|
441
|
-
|
|
464
|
+
# Should skip silently (return 0) when no jac.toml exists
|
|
465
|
+
assert result.returncode == 0
|
|
466
|
+
# No error message should be printed
|
|
467
|
+
assert "No jac.toml found" not in result.stderr
|
|
468
|
+
assert "No jac.toml found" not in result.stdout
|
|
442
469
|
|
|
443
470
|
finally:
|
|
444
471
|
os.chdir(original_cwd)
|
|
445
472
|
|
|
446
473
|
|
|
447
474
|
def test_install_all_packages() -> None:
|
|
448
|
-
"""Test add --
|
|
475
|
+
"""Test add --npm command installs all packages from jac.toml."""
|
|
449
476
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
450
477
|
original_cwd = os.getcwd()
|
|
451
478
|
try:
|
|
@@ -454,24 +481,31 @@ def test_install_all_packages() -> None:
|
|
|
454
481
|
# Create jac.toml with some dependencies
|
|
455
482
|
_create_jac_toml(temp_dir, deps='lodash = "^4.17.21"')
|
|
456
483
|
|
|
457
|
-
# Run add --
|
|
484
|
+
# Run add --npm command without package name
|
|
458
485
|
result = run(
|
|
459
|
-
["jac", "add", "--
|
|
486
|
+
["jac", "add", "--npm"],
|
|
460
487
|
capture_output=True,
|
|
461
488
|
text=True,
|
|
462
489
|
)
|
|
463
490
|
|
|
464
491
|
# Should succeed
|
|
465
492
|
assert result.returncode == 0
|
|
466
|
-
|
|
467
|
-
assert
|
|
493
|
+
# Check for install messages (handles both old and new console formats)
|
|
494
|
+
assert (
|
|
495
|
+
"Installing all npm packages" in result.stdout
|
|
496
|
+
or "Installing all npm packages" in result.stdout.lower()
|
|
497
|
+
)
|
|
498
|
+
assert (
|
|
499
|
+
"Installed all npm packages successfully" in result.stdout
|
|
500
|
+
or "Installed all npm packages" in result.stdout
|
|
501
|
+
)
|
|
468
502
|
|
|
469
503
|
finally:
|
|
470
504
|
os.chdir(original_cwd)
|
|
471
505
|
|
|
472
506
|
|
|
473
507
|
def test_install_package_to_dependencies() -> None:
|
|
474
|
-
"""Test add --
|
|
508
|
+
"""Test add --npm command adds package to dependencies."""
|
|
475
509
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
476
510
|
original_cwd = os.getcwd()
|
|
477
511
|
try:
|
|
@@ -480,17 +514,25 @@ def test_install_package_to_dependencies() -> None:
|
|
|
480
514
|
# Create jac.toml
|
|
481
515
|
config_path = _create_jac_toml(temp_dir)
|
|
482
516
|
|
|
483
|
-
# Run add --
|
|
517
|
+
# Run add --npm command with package name
|
|
484
518
|
result = run(
|
|
485
|
-
["jac", "add", "--
|
|
519
|
+
["jac", "add", "--npm", "lodash"],
|
|
486
520
|
capture_output=True,
|
|
487
521
|
text=True,
|
|
488
522
|
)
|
|
489
523
|
|
|
490
524
|
# Should succeed
|
|
491
525
|
assert result.returncode == 0
|
|
492
|
-
|
|
493
|
-
assert
|
|
526
|
+
# Check for package add messages (handles both old and new console formats)
|
|
527
|
+
assert (
|
|
528
|
+
"Adding lodash (npm)" in result.stdout
|
|
529
|
+
or "lodash" in result.stdout.lower()
|
|
530
|
+
)
|
|
531
|
+
assert (
|
|
532
|
+
"Added 1 package(s) to [dependencies.npm]" in result.stdout
|
|
533
|
+
or "Updated jac.toml" in result.stdout
|
|
534
|
+
or "dependencies.npm" in result.stdout
|
|
535
|
+
)
|
|
494
536
|
|
|
495
537
|
# Verify package was added to jac.toml
|
|
496
538
|
with open(config_path, "rb") as f:
|
|
@@ -503,7 +545,7 @@ def test_install_package_to_dependencies() -> None:
|
|
|
503
545
|
|
|
504
546
|
|
|
505
547
|
def test_install_package_with_version() -> None:
|
|
506
|
-
"""Test add --
|
|
548
|
+
"""Test add --npm command with specific version."""
|
|
507
549
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
508
550
|
original_cwd = os.getcwd()
|
|
509
551
|
try:
|
|
@@ -512,17 +554,25 @@ def test_install_package_with_version() -> None:
|
|
|
512
554
|
# Create jac.toml
|
|
513
555
|
config_path = _create_jac_toml(temp_dir)
|
|
514
556
|
|
|
515
|
-
# Run add --
|
|
557
|
+
# Run add --npm command with package and version
|
|
516
558
|
result = run(
|
|
517
|
-
["jac", "add", "--
|
|
559
|
+
["jac", "add", "--npm", "lodash@^4.17.21"],
|
|
518
560
|
capture_output=True,
|
|
519
561
|
text=True,
|
|
520
562
|
)
|
|
521
563
|
|
|
522
564
|
# Should succeed
|
|
523
565
|
assert result.returncode == 0
|
|
524
|
-
|
|
525
|
-
assert
|
|
566
|
+
# Check for package add messages (handles both old and new console formats)
|
|
567
|
+
assert (
|
|
568
|
+
"Adding lodash (npm)" in result.stdout
|
|
569
|
+
or "lodash" in result.stdout.lower()
|
|
570
|
+
)
|
|
571
|
+
assert (
|
|
572
|
+
"Added 1 package(s) to [dependencies.npm]" in result.stdout
|
|
573
|
+
or "Updated jac.toml" in result.stdout
|
|
574
|
+
or "dependencies.npm" in result.stdout
|
|
575
|
+
)
|
|
526
576
|
|
|
527
577
|
# Verify package was added with correct version
|
|
528
578
|
with open(config_path, "rb") as f:
|
|
@@ -535,7 +585,7 @@ def test_install_package_with_version() -> None:
|
|
|
535
585
|
|
|
536
586
|
|
|
537
587
|
def test_install_package_to_devdependencies() -> None:
|
|
538
|
-
"""Test add --
|
|
588
|
+
"""Test add --npm -d command adds package to dev-dependencies."""
|
|
539
589
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
540
590
|
original_cwd = os.getcwd()
|
|
541
591
|
try:
|
|
@@ -544,9 +594,9 @@ def test_install_package_to_devdependencies() -> None:
|
|
|
544
594
|
# Create jac.toml
|
|
545
595
|
config_path = _create_jac_toml(temp_dir)
|
|
546
596
|
|
|
547
|
-
# Run add --
|
|
597
|
+
# Run add --npm -d command
|
|
548
598
|
run(
|
|
549
|
-
["jac", "add", "--
|
|
599
|
+
["jac", "add", "--npm", "-d", "@types/react"],
|
|
550
600
|
capture_output=True,
|
|
551
601
|
text=True,
|
|
552
602
|
)
|
|
@@ -566,15 +616,15 @@ def test_install_package_to_devdependencies() -> None:
|
|
|
566
616
|
|
|
567
617
|
|
|
568
618
|
def test_install_without_config_json() -> None:
|
|
569
|
-
"""Test add --
|
|
619
|
+
"""Test add --npm command when jac.toml doesn't exist."""
|
|
570
620
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
571
621
|
original_cwd = os.getcwd()
|
|
572
622
|
try:
|
|
573
623
|
os.chdir(temp_dir)
|
|
574
624
|
|
|
575
|
-
# Run add --
|
|
625
|
+
# Run add --npm command without jac.toml
|
|
576
626
|
result = run(
|
|
577
|
-
["jac", "add", "--
|
|
627
|
+
["jac", "add", "--npm", "lodash"],
|
|
578
628
|
capture_output=True,
|
|
579
629
|
text=True,
|
|
580
630
|
)
|
|
@@ -588,13 +638,13 @@ def test_install_without_config_json() -> None:
|
|
|
588
638
|
|
|
589
639
|
|
|
590
640
|
def test_uninstall_without_cl_flag() -> None:
|
|
591
|
-
"""Test remove command without --
|
|
641
|
+
"""Test remove command without --npm flag should fail when no jac.toml exists."""
|
|
592
642
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
593
643
|
original_cwd = os.getcwd()
|
|
594
644
|
try:
|
|
595
645
|
os.chdir(temp_dir)
|
|
596
646
|
|
|
597
|
-
# Run remove command without --
|
|
647
|
+
# Run remove command without --npm flag and without jac.toml
|
|
598
648
|
result = run(
|
|
599
649
|
["jac", "remove", "lodash"],
|
|
600
650
|
capture_output=True,
|
|
@@ -610,7 +660,7 @@ def test_uninstall_without_cl_flag() -> None:
|
|
|
610
660
|
|
|
611
661
|
|
|
612
662
|
def test_uninstall_without_package_name() -> None:
|
|
613
|
-
"""Test remove --
|
|
663
|
+
"""Test remove --npm command without package name should fail."""
|
|
614
664
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
615
665
|
original_cwd = os.getcwd()
|
|
616
666
|
try:
|
|
@@ -619,9 +669,9 @@ def test_uninstall_without_package_name() -> None:
|
|
|
619
669
|
# Create jac.toml
|
|
620
670
|
_create_jac_toml(temp_dir)
|
|
621
671
|
|
|
622
|
-
# Run remove --
|
|
672
|
+
# Run remove --npm command without package name
|
|
623
673
|
result = run(
|
|
624
|
-
["jac", "remove", "--
|
|
674
|
+
["jac", "remove", "--npm"],
|
|
625
675
|
capture_output=True,
|
|
626
676
|
text=True,
|
|
627
677
|
)
|
|
@@ -635,7 +685,7 @@ def test_uninstall_without_package_name() -> None:
|
|
|
635
685
|
|
|
636
686
|
|
|
637
687
|
def test_uninstall_package_from_dependencies() -> None:
|
|
638
|
-
"""Test remove --
|
|
688
|
+
"""Test remove --npm command removes package from dependencies."""
|
|
639
689
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
640
690
|
original_cwd = os.getcwd()
|
|
641
691
|
try:
|
|
@@ -644,9 +694,9 @@ def test_uninstall_package_from_dependencies() -> None:
|
|
|
644
694
|
# Create jac.toml with a package
|
|
645
695
|
config_path = _create_jac_toml(temp_dir, deps='lodash = "^4.17.21"')
|
|
646
696
|
|
|
647
|
-
# Run remove --
|
|
697
|
+
# Run remove --npm command
|
|
648
698
|
result = run(
|
|
649
|
-
["jac", "remove", "--
|
|
699
|
+
["jac", "remove", "--npm", "lodash"],
|
|
650
700
|
capture_output=True,
|
|
651
701
|
text=True,
|
|
652
702
|
)
|
|
@@ -669,7 +719,7 @@ def test_uninstall_package_from_dependencies() -> None:
|
|
|
669
719
|
|
|
670
720
|
|
|
671
721
|
def test_uninstall_package_from_devdependencies() -> None:
|
|
672
|
-
"""Test remove --
|
|
722
|
+
"""Test remove --npm -d command removes package from dev-dependencies."""
|
|
673
723
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
674
724
|
original_cwd = os.getcwd()
|
|
675
725
|
try:
|
|
@@ -680,9 +730,9 @@ def test_uninstall_package_from_devdependencies() -> None:
|
|
|
680
730
|
temp_dir, dev_deps='"@types/react" = "^18.0.0"'
|
|
681
731
|
)
|
|
682
732
|
|
|
683
|
-
# Run remove --
|
|
733
|
+
# Run remove --npm -d command
|
|
684
734
|
result = run(
|
|
685
|
-
["jac", "remove", "--
|
|
735
|
+
["jac", "remove", "--npm", "-d", "@types/react"],
|
|
686
736
|
capture_output=True,
|
|
687
737
|
text=True,
|
|
688
738
|
)
|
|
@@ -704,7 +754,7 @@ def test_uninstall_package_from_devdependencies() -> None:
|
|
|
704
754
|
|
|
705
755
|
|
|
706
756
|
def test_uninstall_nonexistent_package() -> None:
|
|
707
|
-
"""Test remove --
|
|
757
|
+
"""Test remove --npm command with non-existent package should fail."""
|
|
708
758
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
709
759
|
original_cwd = os.getcwd()
|
|
710
760
|
try:
|
|
@@ -713,9 +763,9 @@ def test_uninstall_nonexistent_package() -> None:
|
|
|
713
763
|
# Create jac.toml without the package
|
|
714
764
|
_create_jac_toml(temp_dir)
|
|
715
765
|
|
|
716
|
-
# Run remove --
|
|
766
|
+
# Run remove --npm command with non-existent package
|
|
717
767
|
result = run(
|
|
718
|
-
["jac", "remove", "--
|
|
768
|
+
["jac", "remove", "--npm", "nonexistent-package"],
|
|
719
769
|
capture_output=True,
|
|
720
770
|
text=True,
|
|
721
771
|
)
|
|
@@ -729,15 +779,15 @@ def test_uninstall_nonexistent_package() -> None:
|
|
|
729
779
|
|
|
730
780
|
|
|
731
781
|
def test_uninstall_without_config_toml() -> None:
|
|
732
|
-
"""Test remove --
|
|
782
|
+
"""Test remove --npm command when jac.toml doesn't exist."""
|
|
733
783
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
734
784
|
original_cwd = os.getcwd()
|
|
735
785
|
try:
|
|
736
786
|
os.chdir(temp_dir)
|
|
737
787
|
|
|
738
|
-
# Run remove --
|
|
788
|
+
# Run remove --npm command without jac.toml
|
|
739
789
|
result = run(
|
|
740
|
-
["jac", "remove", "--
|
|
790
|
+
["jac", "remove", "--npm", "lodash"],
|
|
741
791
|
capture_output=True,
|
|
742
792
|
text=True,
|
|
743
793
|
)
|
|
@@ -750,8 +800,74 @@ def test_uninstall_without_config_toml() -> None:
|
|
|
750
800
|
os.chdir(original_cwd)
|
|
751
801
|
|
|
752
802
|
|
|
803
|
+
def test_config_files_from_jac_toml() -> None:
|
|
804
|
+
"""Test that [plugins.client.configs] in jac.toml generates config files."""
|
|
805
|
+
with tempfile.TemporaryDirectory() as temp_dir:
|
|
806
|
+
original_cwd = os.getcwd()
|
|
807
|
+
try:
|
|
808
|
+
os.chdir(temp_dir)
|
|
809
|
+
|
|
810
|
+
# Create jac.toml with postcss and tailwind configs
|
|
811
|
+
toml_content = """[project]
|
|
812
|
+
name = "test-configs"
|
|
813
|
+
version = "1.0.0"
|
|
814
|
+
description = "Test project"
|
|
815
|
+
entry-point = "main.jac"
|
|
816
|
+
|
|
817
|
+
[plugins.client.configs.postcss]
|
|
818
|
+
plugins = ["tailwindcss", "autoprefixer"]
|
|
819
|
+
|
|
820
|
+
[plugins.client.configs.tailwind]
|
|
821
|
+
content = ["./**/*.jac", "./.jac/client/**/*.{js,jsx}"]
|
|
822
|
+
plugins = []
|
|
823
|
+
|
|
824
|
+
[plugins.client.configs.tailwind.theme.extend]
|
|
825
|
+
colors = { primary = "#3490dc" }
|
|
826
|
+
"""
|
|
827
|
+
config_path = os.path.join(temp_dir, "jac.toml")
|
|
828
|
+
with open(config_path, "w") as f:
|
|
829
|
+
f.write(toml_content)
|
|
830
|
+
|
|
831
|
+
# Import and use ViteBundler to generate config files
|
|
832
|
+
from pathlib import Path
|
|
833
|
+
|
|
834
|
+
from jac_client.plugin.src.vite_bundler import ViteBundler
|
|
835
|
+
|
|
836
|
+
bundler = ViteBundler(Path(temp_dir))
|
|
837
|
+
created_files = bundler.create_config_files()
|
|
838
|
+
|
|
839
|
+
# Verify two config files were created
|
|
840
|
+
assert len(created_files) == 2
|
|
841
|
+
|
|
842
|
+
# Verify postcss.config.js was created with correct content
|
|
843
|
+
configs_dir = os.path.join(temp_dir, ".jac", "client", "configs")
|
|
844
|
+
postcss_config = os.path.join(configs_dir, "postcss.config.js")
|
|
845
|
+
assert os.path.exists(postcss_config)
|
|
846
|
+
|
|
847
|
+
with open(postcss_config) as f:
|
|
848
|
+
postcss_content = f.read()
|
|
849
|
+
|
|
850
|
+
assert "module.exports" in postcss_content
|
|
851
|
+
assert "tailwindcss" in postcss_content
|
|
852
|
+
assert "autoprefixer" in postcss_content
|
|
853
|
+
|
|
854
|
+
# Verify tailwind.config.js was created with correct content
|
|
855
|
+
tailwind_config = os.path.join(configs_dir, "tailwind.config.js")
|
|
856
|
+
assert os.path.exists(tailwind_config)
|
|
857
|
+
|
|
858
|
+
with open(tailwind_config) as f:
|
|
859
|
+
tailwind_content = f.read()
|
|
860
|
+
|
|
861
|
+
assert "module.exports" in tailwind_content
|
|
862
|
+
assert "./**/*.jac" in tailwind_content
|
|
863
|
+
assert "#3490dc" in tailwind_content
|
|
864
|
+
|
|
865
|
+
finally:
|
|
866
|
+
os.chdir(original_cwd)
|
|
867
|
+
|
|
868
|
+
|
|
753
869
|
def test_create_cl_and_run_no_root_files() -> None:
|
|
754
|
-
"""Test that jac create --
|
|
870
|
+
"""Test that jac create --use client + jac run doesn't create files outside .jac/ directory."""
|
|
755
871
|
test_project_name = "test-cl-no-root-files"
|
|
756
872
|
|
|
757
873
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
@@ -759,16 +875,16 @@ def test_create_cl_and_run_no_root_files() -> None:
|
|
|
759
875
|
try:
|
|
760
876
|
os.chdir(temp_dir)
|
|
761
877
|
|
|
762
|
-
# Run jac create --
|
|
878
|
+
# Run jac create --use client command
|
|
763
879
|
process = Popen(
|
|
764
|
-
["jac", "create", "--
|
|
880
|
+
["jac", "create", "--use", "client", test_project_name],
|
|
765
881
|
stdin=PIPE,
|
|
766
882
|
stdout=PIPE,
|
|
767
883
|
stderr=PIPE,
|
|
768
884
|
text=True,
|
|
769
885
|
)
|
|
770
886
|
stdout, stderr = process.communicate()
|
|
771
|
-
assert process.returncode == 0, f"jac create --
|
|
887
|
+
assert process.returncode == 0, f"jac create --use client failed: {stderr}"
|
|
772
888
|
|
|
773
889
|
project_path = os.path.join(temp_dir, test_project_name)
|
|
774
890
|
|