@plasmicapp/cli 0.1.337 → 0.1.338
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/dist/actions/export.d.ts +1 -1
- package/dist/actions/init.d.ts +1 -1
- package/dist/index.js +116 -51
- package/dist/lib.js +72 -7
- package/dist/plasmic.schema.json +12 -1
- package/dist/utils/config-utils.d.ts +6 -1
- package/dist/utils/envdetect.d.ts +1 -0
- package/dist/utils/file-utils.d.ts +1 -1
- package/package.json +2 -2
- package/src/__tests__/file-utils.spec.ts +47 -0
- package/src/actions/export.ts +1 -1
- package/src/actions/init.ts +51 -4
- package/src/utils/code-utils.ts +10 -0
- package/src/utils/config-utils.ts +10 -2
- package/src/utils/envdetect.ts +9 -0
- package/src/utils/file-utils.ts +21 -1
package/dist/actions/export.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { CommonArgs } from "..";
|
|
|
2
2
|
import { I18NConfig } from "../utils/config-utils";
|
|
3
3
|
export interface ExportArgs extends CommonArgs {
|
|
4
4
|
projects: readonly string[];
|
|
5
|
-
platform: "" | "react" | "nextjs" | "gatsby";
|
|
5
|
+
platform: "" | "react" | "nextjs" | "gatsby" | "tanstack";
|
|
6
6
|
codeLang: "" | "ts" | "js";
|
|
7
7
|
styleScheme: "" | "css" | "css-modules";
|
|
8
8
|
imagesScheme: "" | "inlined" | "files";
|
package/dist/actions/init.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CommonArgs } from "..";
|
|
2
2
|
export interface InitArgs extends CommonArgs {
|
|
3
3
|
host: string;
|
|
4
|
-
platform: "" | "react" | "nextjs" | "gatsby";
|
|
4
|
+
platform: "" | "react" | "nextjs" | "gatsby" | "tanstack";
|
|
5
5
|
codeLang: "" | "ts" | "js";
|
|
6
6
|
codeScheme: "" | "blackbox";
|
|
7
7
|
styleScheme: "" | "css" | "css-modules";
|
package/dist/index.js
CHANGED
|
@@ -34,9 +34,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
34
34
|
));
|
|
35
35
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
36
36
|
|
|
37
|
-
//
|
|
37
|
+
// node_modules/yargs/build/lib/common-types.js
|
|
38
38
|
var require_common_types = __commonJS({
|
|
39
|
-
"
|
|
39
|
+
"node_modules/yargs/build/lib/common-types.js"(exports) {
|
|
40
40
|
"use strict";
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
42
|
exports.objectKeys = exports.assertSingleKey = exports.assertNotStrictEqual = void 0;
|
|
@@ -56,9 +56,9 @@ var require_common_types = __commonJS({
|
|
|
56
56
|
}
|
|
57
57
|
});
|
|
58
58
|
|
|
59
|
-
//
|
|
59
|
+
// node_modules/yargs/build/lib/is-promise.js
|
|
60
60
|
var require_is_promise = __commonJS({
|
|
61
|
-
"
|
|
61
|
+
"node_modules/yargs/build/lib/is-promise.js"(exports) {
|
|
62
62
|
"use strict";
|
|
63
63
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
64
64
|
exports.isPromise = void 0;
|
|
@@ -69,9 +69,9 @@ var require_is_promise = __commonJS({
|
|
|
69
69
|
}
|
|
70
70
|
});
|
|
71
71
|
|
|
72
|
-
//
|
|
72
|
+
// node_modules/yargs/build/lib/yerror.js
|
|
73
73
|
var require_yerror = __commonJS({
|
|
74
|
-
"
|
|
74
|
+
"node_modules/yargs/build/lib/yerror.js"(exports) {
|
|
75
75
|
"use strict";
|
|
76
76
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
77
77
|
exports.YError = void 0;
|
|
@@ -86,9 +86,9 @@ var require_yerror = __commonJS({
|
|
|
86
86
|
}
|
|
87
87
|
});
|
|
88
88
|
|
|
89
|
-
//
|
|
89
|
+
// node_modules/yargs/build/lib/parse-command.js
|
|
90
90
|
var require_parse_command = __commonJS({
|
|
91
|
-
"
|
|
91
|
+
"node_modules/yargs/build/lib/parse-command.js"(exports) {
|
|
92
92
|
"use strict";
|
|
93
93
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
94
94
|
exports.parseCommand = void 0;
|
|
@@ -127,9 +127,9 @@ var require_parse_command = __commonJS({
|
|
|
127
127
|
}
|
|
128
128
|
});
|
|
129
129
|
|
|
130
|
-
//
|
|
130
|
+
// node_modules/yargs/build/lib/argsert.js
|
|
131
131
|
var require_argsert = __commonJS({
|
|
132
|
-
"
|
|
132
|
+
"node_modules/yargs/build/lib/argsert.js"(exports) {
|
|
133
133
|
"use strict";
|
|
134
134
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
135
135
|
exports.argsert = void 0;
|
|
@@ -191,9 +191,9 @@ var require_argsert = __commonJS({
|
|
|
191
191
|
}
|
|
192
192
|
});
|
|
193
193
|
|
|
194
|
-
//
|
|
194
|
+
// node_modules/yargs/build/lib/middleware.js
|
|
195
195
|
var require_middleware = __commonJS({
|
|
196
|
-
"
|
|
196
|
+
"node_modules/yargs/build/lib/middleware.js"(exports) {
|
|
197
197
|
"use strict";
|
|
198
198
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
199
199
|
exports.applyMiddleware = exports.commandMiddlewareFactory = exports.globalMiddlewareFactory = void 0;
|
|
@@ -399,9 +399,9 @@ var require_decamelize = __commonJS({
|
|
|
399
399
|
}
|
|
400
400
|
});
|
|
401
401
|
|
|
402
|
-
//
|
|
402
|
+
// node_modules/yargs-parser/lib/tokenize-arg-string.js
|
|
403
403
|
var require_tokenize_arg_string = __commonJS({
|
|
404
|
-
"
|
|
404
|
+
"node_modules/yargs-parser/lib/tokenize-arg-string.js"(exports, module2) {
|
|
405
405
|
module2.exports = function(argString) {
|
|
406
406
|
if (Array.isArray(argString)) {
|
|
407
407
|
return argString.map((e) => typeof e !== "string" ? e + "" : e);
|
|
@@ -435,9 +435,9 @@ var require_tokenize_arg_string = __commonJS({
|
|
|
435
435
|
}
|
|
436
436
|
});
|
|
437
437
|
|
|
438
|
-
//
|
|
438
|
+
// node_modules/yargs-parser/index.js
|
|
439
439
|
var require_yargs_parser = __commonJS({
|
|
440
|
-
"
|
|
440
|
+
"node_modules/yargs-parser/index.js"(exports, module2) {
|
|
441
441
|
var camelCase = require_camelcase();
|
|
442
442
|
var decamelize = require_decamelize();
|
|
443
443
|
var path15 = require("path");
|
|
@@ -1226,9 +1226,9 @@ var require_yargs_parser = __commonJS({
|
|
|
1226
1226
|
}
|
|
1227
1227
|
});
|
|
1228
1228
|
|
|
1229
|
-
//
|
|
1229
|
+
// node_modules/yargs/build/lib/command.js
|
|
1230
1230
|
var require_command = __commonJS({
|
|
1231
|
-
"
|
|
1231
|
+
"node_modules/yargs/build/lib/command.js"(exports) {
|
|
1232
1232
|
"use strict";
|
|
1233
1233
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1234
1234
|
exports.isCommandBuilderCallback = exports.isCommandBuilderDefinition = exports.isCommandHandlerDefinition = exports.command = void 0;
|
|
@@ -1589,9 +1589,9 @@ var require_command = __commonJS({
|
|
|
1589
1589
|
}
|
|
1590
1590
|
});
|
|
1591
1591
|
|
|
1592
|
-
//
|
|
1592
|
+
// node_modules/yargs/build/lib/obj-filter.js
|
|
1593
1593
|
var require_obj_filter = __commonJS({
|
|
1594
|
-
"
|
|
1594
|
+
"node_modules/yargs/build/lib/obj-filter.js"(exports) {
|
|
1595
1595
|
"use strict";
|
|
1596
1596
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1597
1597
|
exports.objFilter = void 0;
|
|
@@ -2826,9 +2826,9 @@ var require_ansi_styles = __commonJS({
|
|
|
2826
2826
|
}
|
|
2827
2827
|
});
|
|
2828
2828
|
|
|
2829
|
-
//
|
|
2829
|
+
// node_modules/cliui/node_modules/wrap-ansi/index.js
|
|
2830
2830
|
var require_wrap_ansi = __commonJS({
|
|
2831
|
-
"
|
|
2831
|
+
"node_modules/cliui/node_modules/wrap-ansi/index.js"(exports, module2) {
|
|
2832
2832
|
"use strict";
|
|
2833
2833
|
var stringWidth = require_string_width();
|
|
2834
2834
|
var stripAnsi = require_strip_ansi();
|
|
@@ -2959,9 +2959,9 @@ var require_wrap_ansi = __commonJS({
|
|
|
2959
2959
|
}
|
|
2960
2960
|
});
|
|
2961
2961
|
|
|
2962
|
-
//
|
|
2962
|
+
// node_modules/cliui/index.js
|
|
2963
2963
|
var require_cliui = __commonJS({
|
|
2964
|
-
"
|
|
2964
|
+
"node_modules/cliui/index.js"(exports, module2) {
|
|
2965
2965
|
"use strict";
|
|
2966
2966
|
var stringWidth = require_string_width();
|
|
2967
2967
|
var stripAnsi = require_strip_ansi();
|
|
@@ -3221,9 +3221,9 @@ var require_cliui = __commonJS({
|
|
|
3221
3221
|
}
|
|
3222
3222
|
});
|
|
3223
3223
|
|
|
3224
|
-
//
|
|
3224
|
+
// node_modules/yargs/build/lib/usage.js
|
|
3225
3225
|
var require_usage = __commonJS({
|
|
3226
|
-
"
|
|
3226
|
+
"node_modules/yargs/build/lib/usage.js"(exports) {
|
|
3227
3227
|
"use strict";
|
|
3228
3228
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3229
3229
|
exports.usage = void 0;
|
|
@@ -3701,9 +3701,9 @@ var require_usage = __commonJS({
|
|
|
3701
3701
|
}
|
|
3702
3702
|
});
|
|
3703
3703
|
|
|
3704
|
-
//
|
|
3704
|
+
// node_modules/yargs/build/lib/completion-templates.js
|
|
3705
3705
|
var require_completion_templates = __commonJS({
|
|
3706
|
-
"
|
|
3706
|
+
"node_modules/yargs/build/lib/completion-templates.js"(exports) {
|
|
3707
3707
|
"use strict";
|
|
3708
3708
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3709
3709
|
exports.completionZshTemplate = exports.completionShTemplate = void 0;
|
|
@@ -3758,9 +3758,9 @@ compdef _{{app_name}}_yargs_completions {{app_name}}
|
|
|
3758
3758
|
}
|
|
3759
3759
|
});
|
|
3760
3760
|
|
|
3761
|
-
//
|
|
3761
|
+
// node_modules/yargs/build/lib/completion.js
|
|
3762
3762
|
var require_completion = __commonJS({
|
|
3763
|
-
"
|
|
3763
|
+
"node_modules/yargs/build/lib/completion.js"(exports) {
|
|
3764
3764
|
"use strict";
|
|
3765
3765
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3766
3766
|
exports.completion = void 0;
|
|
@@ -3884,9 +3884,9 @@ var require_completion = __commonJS({
|
|
|
3884
3884
|
}
|
|
3885
3885
|
});
|
|
3886
3886
|
|
|
3887
|
-
//
|
|
3887
|
+
// node_modules/yargs/build/lib/levenshtein.js
|
|
3888
3888
|
var require_levenshtein = __commonJS({
|
|
3889
|
-
"
|
|
3889
|
+
"node_modules/yargs/build/lib/levenshtein.js"(exports) {
|
|
3890
3890
|
"use strict";
|
|
3891
3891
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3892
3892
|
exports.levenshtein = void 0;
|
|
@@ -3927,9 +3927,9 @@ var require_levenshtein = __commonJS({
|
|
|
3927
3927
|
}
|
|
3928
3928
|
});
|
|
3929
3929
|
|
|
3930
|
-
//
|
|
3930
|
+
// node_modules/yargs/build/lib/validation.js
|
|
3931
3931
|
var require_validation = __commonJS({
|
|
3932
|
-
"
|
|
3932
|
+
"node_modules/yargs/build/lib/validation.js"(exports) {
|
|
3933
3933
|
"use strict";
|
|
3934
3934
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3935
3935
|
exports.validation = void 0;
|
|
@@ -4226,9 +4226,9 @@ ${customMsgs.join("\n")}` : "";
|
|
|
4226
4226
|
}
|
|
4227
4227
|
});
|
|
4228
4228
|
|
|
4229
|
-
//
|
|
4229
|
+
// node_modules/yargs/build/lib/apply-extends.js
|
|
4230
4230
|
var require_apply_extends = __commonJS({
|
|
4231
|
-
"
|
|
4231
|
+
"node_modules/yargs/build/lib/apply-extends.js"(exports) {
|
|
4232
4232
|
"use strict";
|
|
4233
4233
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4234
4234
|
exports.applyExtends = void 0;
|
|
@@ -4291,9 +4291,9 @@ var require_apply_extends = __commonJS({
|
|
|
4291
4291
|
}
|
|
4292
4292
|
});
|
|
4293
4293
|
|
|
4294
|
-
//
|
|
4294
|
+
// node_modules/yargs/build/lib/process-argv.js
|
|
4295
4295
|
var require_process_argv = __commonJS({
|
|
4296
|
-
"
|
|
4296
|
+
"node_modules/yargs/build/lib/process-argv.js"(exports) {
|
|
4297
4297
|
"use strict";
|
|
4298
4298
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4299
4299
|
exports.getProcessArgvBin = exports.getProcessArgvWithoutBin = void 0;
|
|
@@ -4784,9 +4784,9 @@ var require_get_caller_file = __commonJS({
|
|
|
4784
4784
|
}
|
|
4785
4785
|
});
|
|
4786
4786
|
|
|
4787
|
-
//
|
|
4787
|
+
// node_modules/yargs/build/lib/yargs.js
|
|
4788
4788
|
var require_yargs = __commonJS({
|
|
4789
|
-
"
|
|
4789
|
+
"node_modules/yargs/build/lib/yargs.js"(exports) {
|
|
4790
4790
|
"use strict";
|
|
4791
4791
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4792
4792
|
exports.isYargsInstance = exports.rebase = exports.Yargs = void 0;
|
|
@@ -5862,9 +5862,9 @@ var require_yargs = __commonJS({
|
|
|
5862
5862
|
}
|
|
5863
5863
|
});
|
|
5864
5864
|
|
|
5865
|
-
//
|
|
5865
|
+
// node_modules/yargs/yargs.js
|
|
5866
5866
|
var require_yargs2 = __commonJS({
|
|
5867
|
-
"
|
|
5867
|
+
"node_modules/yargs/yargs.js"(exports, module2) {
|
|
5868
5868
|
"use strict";
|
|
5869
5869
|
async function requiresNode8OrGreater() {
|
|
5870
5870
|
}
|
|
@@ -5877,9 +5877,9 @@ var require_yargs2 = __commonJS({
|
|
|
5877
5877
|
}
|
|
5878
5878
|
});
|
|
5879
5879
|
|
|
5880
|
-
//
|
|
5880
|
+
// node_modules/yargs/index.js
|
|
5881
5881
|
var require_yargs3 = __commonJS({
|
|
5882
|
-
"
|
|
5882
|
+
"node_modules/yargs/index.js"(exports, module2) {
|
|
5883
5883
|
"use strict";
|
|
5884
5884
|
var yargs2 = require_yargs2();
|
|
5885
5885
|
var processArgv = require_process_argv();
|
|
@@ -499222,6 +499222,9 @@ function makeImportPath(context, fromPath, toPath, stripExt, forceRelative = fal
|
|
|
499222
499222
|
if (stripExt) {
|
|
499223
499223
|
result = stripExtension(result);
|
|
499224
499224
|
}
|
|
499225
|
+
if (result.endsWith(".css") && context.config.platform === "tanstack" && context.config.style.scheme === "css") {
|
|
499226
|
+
result = `${result}?url`;
|
|
499227
|
+
}
|
|
499225
499228
|
return result;
|
|
499226
499229
|
}
|
|
499227
499230
|
function isLocalModulePath(modulePath) {
|
|
@@ -499626,7 +499629,7 @@ function defaultPublicResourcePath(context, project, ...subpaths) {
|
|
|
499626
499629
|
var INDEX_EXT_REGEXP = /\/index\.(jsx|tsx)$/;
|
|
499627
499630
|
var EXT_REGEXP = /\.(jsx|tsx)$/;
|
|
499628
499631
|
function defaultPagePath(context, fileName) {
|
|
499629
|
-
var _a, _b, _c, _d;
|
|
499632
|
+
var _a, _b, _c, _d, _e;
|
|
499630
499633
|
if (context.config.platform === "nextjs") {
|
|
499631
499634
|
if ((_b = (_a = context.config.nextjsConfig) == null ? void 0 : _a.pagesDir) == null ? void 0 : _b.endsWith("app")) {
|
|
499632
499635
|
const matchesIndex = fileName.match(INDEX_EXT_REGEXP);
|
|
@@ -499646,6 +499649,16 @@ function defaultPagePath(context, fileName) {
|
|
|
499646
499649
|
}
|
|
499647
499650
|
} else if (context.config.platform === "gatsby") {
|
|
499648
499651
|
return import_upath3.default.join(((_d = context.config.gatsbyConfig) == null ? void 0 : _d.pagesDir) || "", fileName);
|
|
499652
|
+
} else if (context.config.platform === "tanstack") {
|
|
499653
|
+
let renamedFileName = fileName.replace(/\[(\w+)\]/g, "$$$1");
|
|
499654
|
+
const matchesIndex = fileName.match(INDEX_EXT_REGEXP);
|
|
499655
|
+
if (!matchesIndex) {
|
|
499656
|
+
renamedFileName = renamedFileName.replace(EXT_REGEXP, "/index.$1");
|
|
499657
|
+
}
|
|
499658
|
+
return import_upath3.default.join(
|
|
499659
|
+
((_e = context.config.tanstackConfig) == null ? void 0 : _e.pagesDir) || "",
|
|
499660
|
+
renamedFileName
|
|
499661
|
+
);
|
|
499649
499662
|
} else {
|
|
499650
499663
|
return fileName;
|
|
499651
499664
|
}
|
|
@@ -499792,6 +499805,9 @@ function getAllPaths(context) {
|
|
|
499792
499805
|
if (config.nextjsConfig) {
|
|
499793
499806
|
pushPath(config.nextjsConfig, "pagesDir");
|
|
499794
499807
|
}
|
|
499808
|
+
if (config.tanstackConfig) {
|
|
499809
|
+
pushPath(config.tanstackConfig, "pagesDir");
|
|
499810
|
+
}
|
|
499795
499811
|
return pairs;
|
|
499796
499812
|
}
|
|
499797
499813
|
function assertAllPathsInRootDir(context) {
|
|
@@ -500290,7 +500306,7 @@ function getOrAddProjectLock(context, projectId, branchName, base) {
|
|
|
500290
500306
|
return project;
|
|
500291
500307
|
}
|
|
500292
500308
|
function isPageAwarePlatform(platform) {
|
|
500293
|
-
return platform === "nextjs" || platform === "gatsby";
|
|
500309
|
+
return platform === "nextjs" || platform === "gatsby" || platform === "tanstack";
|
|
500294
500310
|
}
|
|
500295
500311
|
|
|
500296
500312
|
// src/api.ts
|
|
@@ -500826,6 +500842,14 @@ function detectCreateReactApp() {
|
|
|
500826
500842
|
return false;
|
|
500827
500843
|
}
|
|
500828
500844
|
}
|
|
500845
|
+
function detectTanStackApp() {
|
|
500846
|
+
try {
|
|
500847
|
+
const packageJsonContent = getParsedPackageJson();
|
|
500848
|
+
return "@tanstack/react-router" in packageJsonContent.dependencies;
|
|
500849
|
+
} catch {
|
|
500850
|
+
return false;
|
|
500851
|
+
}
|
|
500852
|
+
}
|
|
500829
500853
|
|
|
500830
500854
|
// src/actions/init.ts
|
|
500831
500855
|
async function initPlasmic(opts) {
|
|
@@ -500868,13 +500892,22 @@ function createInitConfig(opts) {
|
|
|
500868
500892
|
pagesDir: opts.pagesDir
|
|
500869
500893
|
}
|
|
500870
500894
|
},
|
|
500895
|
+
...opts.platform === "tanstack" && {
|
|
500896
|
+
tanstackConfig: {
|
|
500897
|
+
pagesDir: opts.pagesDir
|
|
500898
|
+
}
|
|
500899
|
+
},
|
|
500871
500900
|
code: {
|
|
500872
500901
|
...opts.codeLang && { lang: opts.codeLang },
|
|
500873
500902
|
...opts.codeScheme && { scheme: opts.codeScheme },
|
|
500874
500903
|
...opts.reactRuntime && { reactRuntime: opts.reactRuntime }
|
|
500875
500904
|
},
|
|
500876
500905
|
style: {
|
|
500877
|
-
...opts.styleScheme && {
|
|
500906
|
+
...opts.styleScheme && {
|
|
500907
|
+
// Css Modules is not supported yet in SSR for TanStack
|
|
500908
|
+
// https://github.com/TanStack/router/issues/3023
|
|
500909
|
+
scheme: opts.platform === "tanstack" ? "css" : opts.styleScheme
|
|
500910
|
+
}
|
|
500878
500911
|
},
|
|
500879
500912
|
images: {
|
|
500880
500913
|
...opts.imagesScheme && { scheme: opts.imagesScheme },
|
|
@@ -500897,12 +500930,13 @@ function simulatePrompt(question, defaultAnswer, bold = false) {
|
|
|
500897
500930
|
}
|
|
500898
500931
|
async function deriveInitAnswers(opts) {
|
|
500899
500932
|
const plasmicRootDir = opts.config ? import_upath5.default.dirname(opts.config) : opts.baseDir;
|
|
500900
|
-
const platform = !!opts.platform ? opts.platform : detectNextJs() ? "nextjs" : detectGatsby() ? "gatsby" : detectCreateReactApp() ? "react" : "";
|
|
500933
|
+
const platform = !!opts.platform ? opts.platform : detectNextJs() ? "nextjs" : detectGatsby() ? "gatsby" : detectTanStackApp() ? "tanstack" : detectCreateReactApp() ? "react" : "";
|
|
500901
500934
|
const isCra = platform === "react";
|
|
500902
500935
|
const isNext = platform === "nextjs";
|
|
500903
500936
|
const isNextAppDir = isNext && detectNextJsAppDir();
|
|
500904
500937
|
const isGatsby = platform === "gatsby";
|
|
500905
|
-
const
|
|
500938
|
+
const isTanStack = platform === "tanstack";
|
|
500939
|
+
const isGeneric = !isCra && !isNext && !isGatsby && !isTanStack;
|
|
500906
500940
|
const isTypescript = detectTypescript();
|
|
500907
500941
|
if (isNext) {
|
|
500908
500942
|
if (isNextAppDir) {
|
|
@@ -500912,10 +500946,12 @@ async function deriveInitAnswers(opts) {
|
|
|
500912
500946
|
}
|
|
500913
500947
|
} else if (isGatsby) {
|
|
500914
500948
|
logger.info("Detected Gatsby...");
|
|
500949
|
+
} else if (isTanStack) {
|
|
500950
|
+
logger.info("Detected TanStack router app...");
|
|
500915
500951
|
} else if (isCra) {
|
|
500916
500952
|
logger.info("Detected create-react-app...");
|
|
500917
500953
|
}
|
|
500918
|
-
const deriver = isNext ? getNextDefaults(plasmicRootDir, isNextAppDir) : isGatsby ? getGatsbyDefaults(plasmicRootDir) : isCra ? getCraDefaults(plasmicRootDir) : getGenericDefaults(plasmicRootDir);
|
|
500954
|
+
const deriver = isNext ? getNextDefaults(plasmicRootDir, isNextAppDir) : isGatsby ? getGatsbyDefaults(plasmicRootDir) : isTanStack ? getTanStackDefaults(plasmicRootDir) : isCra ? getCraDefaults(plasmicRootDir) : getGenericDefaults(plasmicRootDir);
|
|
500919
500955
|
const srcDir = ensureString(deriver.srcDir);
|
|
500920
500956
|
const getDefaultAnswer = (name, defaultAnswer) => {
|
|
500921
500957
|
if (opts[name]) {
|
|
@@ -501152,6 +501188,35 @@ function getGatsbyDefaults(plasmicRootDir) {
|
|
|
501152
501188
|
alwaysDerived: ["imagesScheme", "pagesDir"]
|
|
501153
501189
|
};
|
|
501154
501190
|
}
|
|
501191
|
+
function getTanStackDefaults(plasmicRootDir) {
|
|
501192
|
+
var _a;
|
|
501193
|
+
const projectRootDir = (_a = findPackageJsonDir(plasmicRootDir)) != null ? _a : plasmicRootDir;
|
|
501194
|
+
return {
|
|
501195
|
+
srcDir: import_upath5.default.relative(
|
|
501196
|
+
plasmicRootDir,
|
|
501197
|
+
import_upath5.default.join(projectRootDir, "src", "components")
|
|
501198
|
+
),
|
|
501199
|
+
pagesDir: (srcDir) => {
|
|
501200
|
+
const absSrcDir = import_upath5.default.join(plasmicRootDir, srcDir);
|
|
501201
|
+
const absPagesDir = import_upath5.default.join(projectRootDir, "src", "routes");
|
|
501202
|
+
const relDir = import_upath5.default.relative(absSrcDir, absPagesDir);
|
|
501203
|
+
return relDir;
|
|
501204
|
+
},
|
|
501205
|
+
styleScheme: "css",
|
|
501206
|
+
imagesScheme: "public-files",
|
|
501207
|
+
imagesPublicDir: (srcDir) => import_upath5.default.relative(
|
|
501208
|
+
import_upath5.default.join(plasmicRootDir, srcDir),
|
|
501209
|
+
import_upath5.default.join(projectRootDir, "public")
|
|
501210
|
+
),
|
|
501211
|
+
imagesPublicUrlPrefix: "/",
|
|
501212
|
+
alwaysDerived: [
|
|
501213
|
+
"styleScheme",
|
|
501214
|
+
"imagesScheme",
|
|
501215
|
+
"imagesPublicDir",
|
|
501216
|
+
"pagesDir"
|
|
501217
|
+
]
|
|
501218
|
+
};
|
|
501219
|
+
}
|
|
501155
501220
|
function getCraDefaults(plasmicRootDir) {
|
|
501156
501221
|
var _a;
|
|
501157
501222
|
const projectRootDir = (_a = findPackageJsonDir(plasmicRootDir)) != null ? _a : plasmicRootDir;
|
|
@@ -501185,7 +501250,7 @@ var INIT_ARGS_DESCRIPTION = {
|
|
|
501185
501250
|
platform: {
|
|
501186
501251
|
shortDescription: "Target platform",
|
|
501187
501252
|
longDescription: "Target platform to generate code for",
|
|
501188
|
-
choices: ["react", "nextjs", "gatsby"]
|
|
501253
|
+
choices: ["react", "nextjs", "gatsby", "tanstack"]
|
|
501189
501254
|
},
|
|
501190
501255
|
codeLang: {
|
|
501191
501256
|
shortDescription: "Target language",
|
package/dist/lib.js
CHANGED
|
@@ -494564,6 +494564,9 @@ function makeImportPath(context, fromPath, toPath, stripExt, forceRelative = fal
|
|
|
494564
494564
|
if (stripExt) {
|
|
494565
494565
|
result = stripExtension(result);
|
|
494566
494566
|
}
|
|
494567
|
+
if (result.endsWith(".css") && context.config.platform === "tanstack" && context.config.style.scheme === "css") {
|
|
494568
|
+
result = `${result}?url`;
|
|
494569
|
+
}
|
|
494567
494570
|
return result;
|
|
494568
494571
|
}
|
|
494569
494572
|
function isLocalModulePath(modulePath) {
|
|
@@ -494968,7 +494971,7 @@ function defaultPublicResourcePath(context, project, ...subpaths) {
|
|
|
494968
494971
|
var INDEX_EXT_REGEXP = /\/index\.(jsx|tsx)$/;
|
|
494969
494972
|
var EXT_REGEXP = /\.(jsx|tsx)$/;
|
|
494970
494973
|
function defaultPagePath(context, fileName) {
|
|
494971
|
-
var _a, _b, _c, _d;
|
|
494974
|
+
var _a, _b, _c, _d, _e;
|
|
494972
494975
|
if (context.config.platform === "nextjs") {
|
|
494973
494976
|
if ((_b = (_a = context.config.nextjsConfig) == null ? void 0 : _a.pagesDir) == null ? void 0 : _b.endsWith("app")) {
|
|
494974
494977
|
const matchesIndex = fileName.match(INDEX_EXT_REGEXP);
|
|
@@ -494988,6 +494991,16 @@ function defaultPagePath(context, fileName) {
|
|
|
494988
494991
|
}
|
|
494989
494992
|
} else if (context.config.platform === "gatsby") {
|
|
494990
494993
|
return import_upath3.default.join(((_d = context.config.gatsbyConfig) == null ? void 0 : _d.pagesDir) || "", fileName);
|
|
494994
|
+
} else if (context.config.platform === "tanstack") {
|
|
494995
|
+
let renamedFileName = fileName.replace(/\[(\w+)\]/g, "$$$1");
|
|
494996
|
+
const matchesIndex = fileName.match(INDEX_EXT_REGEXP);
|
|
494997
|
+
if (!matchesIndex) {
|
|
494998
|
+
renamedFileName = renamedFileName.replace(EXT_REGEXP, "/index.$1");
|
|
494999
|
+
}
|
|
495000
|
+
return import_upath3.default.join(
|
|
495001
|
+
((_e = context.config.tanstackConfig) == null ? void 0 : _e.pagesDir) || "",
|
|
495002
|
+
renamedFileName
|
|
495003
|
+
);
|
|
494991
495004
|
} else {
|
|
494992
495005
|
return fileName;
|
|
494993
495006
|
}
|
|
@@ -495134,6 +495147,9 @@ function getAllPaths(context) {
|
|
|
495134
495147
|
if (config.nextjsConfig) {
|
|
495135
495148
|
pushPath(config.nextjsConfig, "pagesDir");
|
|
495136
495149
|
}
|
|
495150
|
+
if (config.tanstackConfig) {
|
|
495151
|
+
pushPath(config.tanstackConfig, "pagesDir");
|
|
495152
|
+
}
|
|
495137
495153
|
return pairs;
|
|
495138
495154
|
}
|
|
495139
495155
|
function assertAllPathsInRootDir(context) {
|
|
@@ -495632,7 +495648,7 @@ function getOrAddProjectLock(context, projectId, branchName, base) {
|
|
|
495632
495648
|
return project;
|
|
495633
495649
|
}
|
|
495634
495650
|
function isPageAwarePlatform(platform) {
|
|
495635
|
-
return platform === "nextjs" || platform === "gatsby";
|
|
495651
|
+
return platform === "nextjs" || platform === "gatsby" || platform === "tanstack";
|
|
495636
495652
|
}
|
|
495637
495653
|
|
|
495638
495654
|
// src/api.ts
|
|
@@ -496168,6 +496184,14 @@ function detectCreateReactApp() {
|
|
|
496168
496184
|
return false;
|
|
496169
496185
|
}
|
|
496170
496186
|
}
|
|
496187
|
+
function detectTanStackApp() {
|
|
496188
|
+
try {
|
|
496189
|
+
const packageJsonContent = getParsedPackageJson();
|
|
496190
|
+
return "@tanstack/react-router" in packageJsonContent.dependencies;
|
|
496191
|
+
} catch {
|
|
496192
|
+
return false;
|
|
496193
|
+
}
|
|
496194
|
+
}
|
|
496171
496195
|
|
|
496172
496196
|
// src/actions/init.ts
|
|
496173
496197
|
async function initPlasmic(opts) {
|
|
@@ -496210,13 +496234,22 @@ function createInitConfig(opts) {
|
|
|
496210
496234
|
pagesDir: opts.pagesDir
|
|
496211
496235
|
}
|
|
496212
496236
|
},
|
|
496237
|
+
...opts.platform === "tanstack" && {
|
|
496238
|
+
tanstackConfig: {
|
|
496239
|
+
pagesDir: opts.pagesDir
|
|
496240
|
+
}
|
|
496241
|
+
},
|
|
496213
496242
|
code: {
|
|
496214
496243
|
...opts.codeLang && { lang: opts.codeLang },
|
|
496215
496244
|
...opts.codeScheme && { scheme: opts.codeScheme },
|
|
496216
496245
|
...opts.reactRuntime && { reactRuntime: opts.reactRuntime }
|
|
496217
496246
|
},
|
|
496218
496247
|
style: {
|
|
496219
|
-
...opts.styleScheme && {
|
|
496248
|
+
...opts.styleScheme && {
|
|
496249
|
+
// Css Modules is not supported yet in SSR for TanStack
|
|
496250
|
+
// https://github.com/TanStack/router/issues/3023
|
|
496251
|
+
scheme: opts.platform === "tanstack" ? "css" : opts.styleScheme
|
|
496252
|
+
}
|
|
496220
496253
|
},
|
|
496221
496254
|
images: {
|
|
496222
496255
|
...opts.imagesScheme && { scheme: opts.imagesScheme },
|
|
@@ -496239,12 +496272,13 @@ function simulatePrompt(question, defaultAnswer, bold = false) {
|
|
|
496239
496272
|
}
|
|
496240
496273
|
async function deriveInitAnswers(opts) {
|
|
496241
496274
|
const plasmicRootDir = opts.config ? import_upath5.default.dirname(opts.config) : opts.baseDir;
|
|
496242
|
-
const platform = !!opts.platform ? opts.platform : detectNextJs() ? "nextjs" : detectGatsby() ? "gatsby" : detectCreateReactApp() ? "react" : "";
|
|
496275
|
+
const platform = !!opts.platform ? opts.platform : detectNextJs() ? "nextjs" : detectGatsby() ? "gatsby" : detectTanStackApp() ? "tanstack" : detectCreateReactApp() ? "react" : "";
|
|
496243
496276
|
const isCra = platform === "react";
|
|
496244
496277
|
const isNext = platform === "nextjs";
|
|
496245
496278
|
const isNextAppDir = isNext && detectNextJsAppDir();
|
|
496246
496279
|
const isGatsby = platform === "gatsby";
|
|
496247
|
-
const
|
|
496280
|
+
const isTanStack = platform === "tanstack";
|
|
496281
|
+
const isGeneric = !isCra && !isNext && !isGatsby && !isTanStack;
|
|
496248
496282
|
const isTypescript = detectTypescript();
|
|
496249
496283
|
if (isNext) {
|
|
496250
496284
|
if (isNextAppDir) {
|
|
@@ -496254,10 +496288,12 @@ async function deriveInitAnswers(opts) {
|
|
|
496254
496288
|
}
|
|
496255
496289
|
} else if (isGatsby) {
|
|
496256
496290
|
logger.info("Detected Gatsby...");
|
|
496291
|
+
} else if (isTanStack) {
|
|
496292
|
+
logger.info("Detected TanStack router app...");
|
|
496257
496293
|
} else if (isCra) {
|
|
496258
496294
|
logger.info("Detected create-react-app...");
|
|
496259
496295
|
}
|
|
496260
|
-
const deriver = isNext ? getNextDefaults(plasmicRootDir, isNextAppDir) : isGatsby ? getGatsbyDefaults(plasmicRootDir) : isCra ? getCraDefaults(plasmicRootDir) : getGenericDefaults(plasmicRootDir);
|
|
496296
|
+
const deriver = isNext ? getNextDefaults(plasmicRootDir, isNextAppDir) : isGatsby ? getGatsbyDefaults(plasmicRootDir) : isTanStack ? getTanStackDefaults(plasmicRootDir) : isCra ? getCraDefaults(plasmicRootDir) : getGenericDefaults(plasmicRootDir);
|
|
496261
496297
|
const srcDir = ensureString(deriver.srcDir);
|
|
496262
496298
|
const getDefaultAnswer = (name, defaultAnswer) => {
|
|
496263
496299
|
if (opts[name]) {
|
|
@@ -496494,6 +496530,35 @@ function getGatsbyDefaults(plasmicRootDir) {
|
|
|
496494
496530
|
alwaysDerived: ["imagesScheme", "pagesDir"]
|
|
496495
496531
|
};
|
|
496496
496532
|
}
|
|
496533
|
+
function getTanStackDefaults(plasmicRootDir) {
|
|
496534
|
+
var _a;
|
|
496535
|
+
const projectRootDir = (_a = findPackageJsonDir(plasmicRootDir)) != null ? _a : plasmicRootDir;
|
|
496536
|
+
return {
|
|
496537
|
+
srcDir: import_upath5.default.relative(
|
|
496538
|
+
plasmicRootDir,
|
|
496539
|
+
import_upath5.default.join(projectRootDir, "src", "components")
|
|
496540
|
+
),
|
|
496541
|
+
pagesDir: (srcDir) => {
|
|
496542
|
+
const absSrcDir = import_upath5.default.join(plasmicRootDir, srcDir);
|
|
496543
|
+
const absPagesDir = import_upath5.default.join(projectRootDir, "src", "routes");
|
|
496544
|
+
const relDir = import_upath5.default.relative(absSrcDir, absPagesDir);
|
|
496545
|
+
return relDir;
|
|
496546
|
+
},
|
|
496547
|
+
styleScheme: "css",
|
|
496548
|
+
imagesScheme: "public-files",
|
|
496549
|
+
imagesPublicDir: (srcDir) => import_upath5.default.relative(
|
|
496550
|
+
import_upath5.default.join(plasmicRootDir, srcDir),
|
|
496551
|
+
import_upath5.default.join(projectRootDir, "public")
|
|
496552
|
+
),
|
|
496553
|
+
imagesPublicUrlPrefix: "/",
|
|
496554
|
+
alwaysDerived: [
|
|
496555
|
+
"styleScheme",
|
|
496556
|
+
"imagesScheme",
|
|
496557
|
+
"imagesPublicDir",
|
|
496558
|
+
"pagesDir"
|
|
496559
|
+
]
|
|
496560
|
+
};
|
|
496561
|
+
}
|
|
496497
496562
|
function getCraDefaults(plasmicRootDir) {
|
|
496498
496563
|
var _a;
|
|
496499
496564
|
const projectRootDir = (_a = findPackageJsonDir(plasmicRootDir)) != null ? _a : plasmicRootDir;
|
|
@@ -496527,7 +496592,7 @@ var INIT_ARGS_DESCRIPTION = {
|
|
|
496527
496592
|
platform: {
|
|
496528
496593
|
shortDescription: "Target platform",
|
|
496529
496594
|
longDescription: "Target platform to generate code for",
|
|
496530
|
-
choices: ["react", "nextjs", "gatsby"]
|
|
496595
|
+
choices: ["react", "nextjs", "gatsby", "tanstack"]
|
|
496531
496596
|
},
|
|
496532
496597
|
codeLang: {
|
|
496533
496598
|
shortDescription: "Target language",
|
package/dist/plasmic.schema.json
CHANGED
|
@@ -568,7 +568,8 @@
|
|
|
568
568
|
"enum": [
|
|
569
569
|
"gatsby",
|
|
570
570
|
"nextjs",
|
|
571
|
-
"react"
|
|
571
|
+
"react",
|
|
572
|
+
"tanstack"
|
|
572
573
|
],
|
|
573
574
|
"type": "string"
|
|
574
575
|
},
|
|
@@ -594,6 +595,16 @@
|
|
|
594
595
|
"$ref": "#/definitions/StyleConfig",
|
|
595
596
|
"description": "Config for style generation"
|
|
596
597
|
},
|
|
598
|
+
"tanstackConfig": {
|
|
599
|
+
"description": "Tanstack-specific config",
|
|
600
|
+
"properties": {
|
|
601
|
+
"pagesDir": {
|
|
602
|
+
"description": "The folder containing page components source files.",
|
|
603
|
+
"type": "string"
|
|
604
|
+
}
|
|
605
|
+
},
|
|
606
|
+
"type": "object"
|
|
607
|
+
},
|
|
597
608
|
"tokens": {
|
|
598
609
|
"$ref": "#/definitions/TokensConfig",
|
|
599
610
|
"description": "Config for style tokens"
|
|
@@ -10,7 +10,7 @@ export declare const ENV_AUTH_USER = "PLASMIC_AUTH_USER";
|
|
|
10
10
|
export declare const ENV_AUTH_TOKEN = "PLASMIC_AUTH_TOKEN";
|
|
11
11
|
export interface PlasmicConfig {
|
|
12
12
|
/** Target platform to generate code for */
|
|
13
|
-
platform: "react" | "nextjs" | "gatsby";
|
|
13
|
+
platform: "react" | "nextjs" | "gatsby" | "tanstack";
|
|
14
14
|
/**
|
|
15
15
|
* The folder containing the component source files; this is the default place where
|
|
16
16
|
* all files are generated and stored.
|
|
@@ -34,6 +34,11 @@ export interface PlasmicConfig {
|
|
|
34
34
|
/** The folder containing page components source files. */
|
|
35
35
|
pagesDir?: string;
|
|
36
36
|
};
|
|
37
|
+
/** Tanstack-specific config */
|
|
38
|
+
tanstackConfig?: {
|
|
39
|
+
/** The folder containing page components source files. */
|
|
40
|
+
pagesDir?: string;
|
|
41
|
+
};
|
|
37
42
|
/** Config for code generation */
|
|
38
43
|
code: CodeConfig;
|
|
39
44
|
/** Config for pictures */
|
|
@@ -9,7 +9,7 @@ export declare function writeFileContentRaw(filePath: string, content: string |
|
|
|
9
9
|
export declare function defaultResourcePath(context: PlasmicContext, project: ProjectConfig | ProjectMetaBundle | string, ...subpaths: string[]): string;
|
|
10
10
|
export declare function defaultPublicResourcePath(context: PlasmicContext, project: ProjectConfig, ...subpaths: string[]): string;
|
|
11
11
|
export declare function defaultPagePath(context: {
|
|
12
|
-
config: Pick<PlasmicConfig, "platform" | "gatsbyConfig" | "nextjsConfig">;
|
|
12
|
+
config: Pick<PlasmicConfig, "platform" | "gatsbyConfig" | "nextjsConfig" | "tanstackConfig">;
|
|
13
13
|
}, fileName: string): string;
|
|
14
14
|
/**
|
|
15
15
|
* Returns true iff paths `a` and `b` resolve to the same page URI. For
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plasmicapp/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.338",
|
|
4
4
|
"description": "plasmic cli for syncing local code with Plasmic designs",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=12"
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"wrap-ansi": "^7.0.0",
|
|
84
84
|
"yargs": "^15.4.1"
|
|
85
85
|
},
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "7199e5b0c2c94b6e95c81c8120d9861faf98d7ee"
|
|
87
87
|
}
|
|
@@ -102,4 +102,51 @@ describe("defaultPagePath", () => {
|
|
|
102
102
|
)
|
|
103
103
|
).toBe("../app/not-index/page.tsx");
|
|
104
104
|
});
|
|
105
|
+
it("handles tanstack pagesDir", () => {
|
|
106
|
+
expect(
|
|
107
|
+
defaultPagePath(
|
|
108
|
+
{
|
|
109
|
+
config: {
|
|
110
|
+
platform: "tanstack",
|
|
111
|
+
tanstackConfig: { pagesDir: "../routes" },
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
"/index.tsx"
|
|
115
|
+
)
|
|
116
|
+
).toBe("../routes/index.tsx");
|
|
117
|
+
expect(
|
|
118
|
+
defaultPagePath(
|
|
119
|
+
{
|
|
120
|
+
config: {
|
|
121
|
+
platform: "tanstack",
|
|
122
|
+
tanstackConfig: { pagesDir: "../routes" },
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
"/nested/index.tsx"
|
|
126
|
+
)
|
|
127
|
+
).toBe("../routes/nested/index.tsx");
|
|
128
|
+
|
|
129
|
+
expect(
|
|
130
|
+
defaultPagePath(
|
|
131
|
+
{
|
|
132
|
+
config: {
|
|
133
|
+
platform: "tanstack",
|
|
134
|
+
tanstackConfig: { pagesDir: "../routes" },
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
"/post.tsx"
|
|
138
|
+
)
|
|
139
|
+
).toBe("../routes/post/index.tsx");
|
|
140
|
+
expect(
|
|
141
|
+
defaultPagePath(
|
|
142
|
+
{
|
|
143
|
+
config: {
|
|
144
|
+
platform: "tanstack",
|
|
145
|
+
tanstackConfig: { pagesDir: "../routes" },
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
"/post/[postId].tsx"
|
|
149
|
+
)
|
|
150
|
+
).toBe("../routes/post/$postId/index.tsx");
|
|
151
|
+
});
|
|
105
152
|
});
|
package/src/actions/export.ts
CHANGED
|
@@ -24,7 +24,7 @@ import { DEFAULT_SPLITS_PROVIDER_NAME } from "./sync-splits-provider";
|
|
|
24
24
|
|
|
25
25
|
export interface ExportArgs extends CommonArgs {
|
|
26
26
|
projects: readonly string[];
|
|
27
|
-
platform: "" | "react" | "nextjs" | "gatsby";
|
|
27
|
+
platform: "" | "react" | "nextjs" | "gatsby" | "tanstack";
|
|
28
28
|
codeLang: "" | "ts" | "js";
|
|
29
29
|
styleScheme: "" | "css" | "css-modules";
|
|
30
30
|
imagesScheme: "" | "inlined" | "files";
|
package/src/actions/init.ts
CHANGED
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
detectGatsby,
|
|
21
21
|
detectNextJs,
|
|
22
22
|
detectNextJsAppDir,
|
|
23
|
+
detectTanStackApp,
|
|
23
24
|
detectTypescript,
|
|
24
25
|
} from "../utils/envdetect";
|
|
25
26
|
import { existsBuffered } from "../utils/file-utils";
|
|
@@ -33,7 +34,7 @@ import { confirmWithUser } from "../utils/user-utils";
|
|
|
33
34
|
|
|
34
35
|
export interface InitArgs extends CommonArgs {
|
|
35
36
|
host: string;
|
|
36
|
-
platform: "" | "react" | "nextjs" | "gatsby";
|
|
37
|
+
platform: "" | "react" | "nextjs" | "gatsby" | "tanstack";
|
|
37
38
|
codeLang: "" | "ts" | "js";
|
|
38
39
|
codeScheme: "" | "blackbox";
|
|
39
40
|
styleScheme: "" | "css" | "css-modules";
|
|
@@ -97,13 +98,22 @@ function createInitConfig(opts: Omit<InitArgs, "baseDir">): PlasmicConfig {
|
|
|
97
98
|
pagesDir: opts.pagesDir,
|
|
98
99
|
},
|
|
99
100
|
}),
|
|
101
|
+
...(opts.platform === "tanstack" && {
|
|
102
|
+
tanstackConfig: {
|
|
103
|
+
pagesDir: opts.pagesDir,
|
|
104
|
+
},
|
|
105
|
+
}),
|
|
100
106
|
code: {
|
|
101
107
|
...(opts.codeLang && { lang: opts.codeLang }),
|
|
102
108
|
...(opts.codeScheme && { scheme: opts.codeScheme }),
|
|
103
109
|
...(opts.reactRuntime && { reactRuntime: opts.reactRuntime }),
|
|
104
110
|
},
|
|
105
111
|
style: {
|
|
106
|
-
...(opts.styleScheme && {
|
|
112
|
+
...(opts.styleScheme && {
|
|
113
|
+
// Css Modules is not supported yet in SSR for TanStack
|
|
114
|
+
// https://github.com/TanStack/router/issues/3023
|
|
115
|
+
scheme: opts.platform === "tanstack" ? "css" : opts.styleScheme,
|
|
116
|
+
}),
|
|
107
117
|
},
|
|
108
118
|
images: {
|
|
109
119
|
...(opts.imagesScheme && { scheme: opts.imagesScheme }),
|
|
@@ -165,6 +175,8 @@ async function deriveInitAnswers(
|
|
|
165
175
|
? "nextjs"
|
|
166
176
|
: detectGatsby()
|
|
167
177
|
? "gatsby"
|
|
178
|
+
: detectTanStackApp()
|
|
179
|
+
? "tanstack"
|
|
168
180
|
: detectCreateReactApp()
|
|
169
181
|
? "react"
|
|
170
182
|
: "";
|
|
@@ -172,7 +184,8 @@ async function deriveInitAnswers(
|
|
|
172
184
|
const isNext = platform === "nextjs";
|
|
173
185
|
const isNextAppDir = isNext && detectNextJsAppDir();
|
|
174
186
|
const isGatsby = platform === "gatsby";
|
|
175
|
-
const
|
|
187
|
+
const isTanStack = platform === "tanstack";
|
|
188
|
+
const isGeneric = !isCra && !isNext && !isGatsby && !isTanStack;
|
|
176
189
|
const isTypescript = detectTypescript();
|
|
177
190
|
|
|
178
191
|
if (isNext) {
|
|
@@ -183,6 +196,8 @@ async function deriveInitAnswers(
|
|
|
183
196
|
}
|
|
184
197
|
} else if (isGatsby) {
|
|
185
198
|
logger.info("Detected Gatsby...");
|
|
199
|
+
} else if (isTanStack) {
|
|
200
|
+
logger.info("Detected TanStack router app...");
|
|
186
201
|
} else if (isCra) {
|
|
187
202
|
logger.info("Detected create-react-app...");
|
|
188
203
|
}
|
|
@@ -192,6 +207,8 @@ async function deriveInitAnswers(
|
|
|
192
207
|
? getNextDefaults(plasmicRootDir, isNextAppDir)
|
|
193
208
|
: isGatsby
|
|
194
209
|
? getGatsbyDefaults(plasmicRootDir)
|
|
210
|
+
: isTanStack
|
|
211
|
+
? getTanStackDefaults(plasmicRootDir)
|
|
195
212
|
: isCra
|
|
196
213
|
? getCraDefaults(plasmicRootDir)
|
|
197
214
|
: getGenericDefaults(plasmicRootDir);
|
|
@@ -473,6 +490,36 @@ function getGatsbyDefaults(plasmicRootDir: string): DefaultDeriver {
|
|
|
473
490
|
};
|
|
474
491
|
}
|
|
475
492
|
|
|
493
|
+
function getTanStackDefaults(plasmicRootDir: string): DefaultDeriver {
|
|
494
|
+
const projectRootDir = findPackageJsonDir(plasmicRootDir) ?? plasmicRootDir;
|
|
495
|
+
return {
|
|
496
|
+
srcDir: path.relative(
|
|
497
|
+
plasmicRootDir,
|
|
498
|
+
path.join(projectRootDir, "src", "components")
|
|
499
|
+
),
|
|
500
|
+
pagesDir: (srcDir: string) => {
|
|
501
|
+
const absSrcDir = path.join(plasmicRootDir, srcDir);
|
|
502
|
+
const absPagesDir = path.join(projectRootDir, "src", "routes");
|
|
503
|
+
const relDir = path.relative(absSrcDir, absPagesDir);
|
|
504
|
+
return relDir;
|
|
505
|
+
},
|
|
506
|
+
styleScheme: "css",
|
|
507
|
+
imagesScheme: "public-files",
|
|
508
|
+
imagesPublicDir: (srcDir: string) =>
|
|
509
|
+
path.relative(
|
|
510
|
+
path.join(plasmicRootDir, srcDir),
|
|
511
|
+
path.join(projectRootDir, "public")
|
|
512
|
+
),
|
|
513
|
+
imagesPublicUrlPrefix: "/",
|
|
514
|
+
alwaysDerived: [
|
|
515
|
+
"styleScheme",
|
|
516
|
+
"imagesScheme",
|
|
517
|
+
"imagesPublicDir",
|
|
518
|
+
"pagesDir",
|
|
519
|
+
],
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
|
|
476
523
|
function getCraDefaults(plasmicRootDir: string): DefaultDeriver {
|
|
477
524
|
const projectRootDir = findPackageJsonDir(plasmicRootDir) ?? plasmicRootDir;
|
|
478
525
|
return {
|
|
@@ -519,7 +566,7 @@ const INIT_ARGS_DESCRIPTION: {
|
|
|
519
566
|
platform: {
|
|
520
567
|
shortDescription: "Target platform",
|
|
521
568
|
longDescription: "Target platform to generate code for",
|
|
522
|
-
choices: ["react", "nextjs", "gatsby"],
|
|
569
|
+
choices: ["react", "nextjs", "gatsby", "tanstack"],
|
|
523
570
|
},
|
|
524
571
|
codeLang: {
|
|
525
572
|
shortDescription: "Target language",
|
package/src/utils/code-utils.ts
CHANGED
|
@@ -528,6 +528,16 @@ function makeImportPath(
|
|
|
528
528
|
if (stripExt) {
|
|
529
529
|
result = stripExtension(result);
|
|
530
530
|
}
|
|
531
|
+
|
|
532
|
+
if (
|
|
533
|
+
result.endsWith(".css") &&
|
|
534
|
+
context.config.platform === "tanstack" &&
|
|
535
|
+
context.config.style.scheme === "css"
|
|
536
|
+
) {
|
|
537
|
+
// In Tanstack we import css as url such as ".css?url" at the moment
|
|
538
|
+
result = `${result}?url`;
|
|
539
|
+
}
|
|
540
|
+
|
|
531
541
|
return result;
|
|
532
542
|
}
|
|
533
543
|
|
|
@@ -27,7 +27,7 @@ export const ENV_AUTH_TOKEN = "PLASMIC_AUTH_TOKEN";
|
|
|
27
27
|
|
|
28
28
|
export interface PlasmicConfig {
|
|
29
29
|
/** Target platform to generate code for */
|
|
30
|
-
platform: "react" | "nextjs" | "gatsby";
|
|
30
|
+
platform: "react" | "nextjs" | "gatsby" | "tanstack";
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* The folder containing the component source files; this is the default place where
|
|
@@ -56,6 +56,12 @@ export interface PlasmicConfig {
|
|
|
56
56
|
pagesDir?: string;
|
|
57
57
|
};
|
|
58
58
|
|
|
59
|
+
/** Tanstack-specific config */
|
|
60
|
+
tanstackConfig?: {
|
|
61
|
+
/** The folder containing page components source files. */
|
|
62
|
+
pagesDir?: string;
|
|
63
|
+
};
|
|
64
|
+
|
|
59
65
|
/** Config for code generation */
|
|
60
66
|
code: CodeConfig;
|
|
61
67
|
|
|
@@ -636,5 +642,7 @@ export function getOrAddProjectLock(
|
|
|
636
642
|
}
|
|
637
643
|
|
|
638
644
|
export function isPageAwarePlatform(platform: string): boolean {
|
|
639
|
-
return
|
|
645
|
+
return (
|
|
646
|
+
platform === "nextjs" || platform === "gatsby" || platform === "tanstack"
|
|
647
|
+
);
|
|
640
648
|
}
|
package/src/utils/envdetect.ts
CHANGED
|
@@ -46,3 +46,12 @@ export function detectCreateReactApp() {
|
|
|
46
46
|
return false;
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
+
|
|
50
|
+
export function detectTanStackApp() {
|
|
51
|
+
try {
|
|
52
|
+
const packageJsonContent = getParsedPackageJson();
|
|
53
|
+
return "@tanstack/react-router" in packageJsonContent.dependencies;
|
|
54
|
+
} catch {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
}
|
package/src/utils/file-utils.ts
CHANGED
|
@@ -81,7 +81,10 @@ const EXT_REGEXP = /\.(jsx|tsx)$/;
|
|
|
81
81
|
|
|
82
82
|
export function defaultPagePath(
|
|
83
83
|
context: {
|
|
84
|
-
config: Pick<
|
|
84
|
+
config: Pick<
|
|
85
|
+
PlasmicConfig,
|
|
86
|
+
"platform" | "gatsbyConfig" | "nextjsConfig" | "tanstackConfig"
|
|
87
|
+
>;
|
|
85
88
|
},
|
|
86
89
|
fileName: string
|
|
87
90
|
) {
|
|
@@ -106,6 +109,20 @@ export function defaultPagePath(
|
|
|
106
109
|
}
|
|
107
110
|
} else if (context.config.platform === "gatsby") {
|
|
108
111
|
return path.join(context.config.gatsbyConfig?.pagesDir || "", fileName);
|
|
112
|
+
} else if (context.config.platform === "tanstack") {
|
|
113
|
+
// use $ for dynamic paths, convert "/posts/[postId]" to "/posts/$postId"
|
|
114
|
+
let renamedFileName = fileName.replace(/\[(\w+)\]/g, "$$$1");
|
|
115
|
+
|
|
116
|
+
const matchesIndex = fileName.match(INDEX_EXT_REGEXP);
|
|
117
|
+
if (!matchesIndex) {
|
|
118
|
+
// convert "/foo/bar.tsx" to "/foo/bar/index.tsx"
|
|
119
|
+
renamedFileName = renamedFileName.replace(EXT_REGEXP, "/index.$1");
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return path.join(
|
|
123
|
+
context.config.tanstackConfig?.pagesDir || "",
|
|
124
|
+
renamedFileName
|
|
125
|
+
);
|
|
109
126
|
} else {
|
|
110
127
|
return fileName;
|
|
111
128
|
}
|
|
@@ -351,6 +368,9 @@ function getAllPaths(context: PlasmicContext): BundleKeyPair[] {
|
|
|
351
368
|
if (config.nextjsConfig) {
|
|
352
369
|
pushPath(config.nextjsConfig, "pagesDir");
|
|
353
370
|
}
|
|
371
|
+
if (config.tanstackConfig) {
|
|
372
|
+
pushPath(config.tanstackConfig, "pagesDir");
|
|
373
|
+
}
|
|
354
374
|
|
|
355
375
|
return pairs;
|
|
356
376
|
}
|