cordo 2.11.1 → 2.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MissingContextError } from "../../errors/builtin/missing-context"
|
|
2
|
+
import { FunctCompiler } from "../../functions/compiler"
|
|
2
3
|
import { Hooks } from "../hooks"
|
|
3
4
|
import type { CordoInteraction } from "../interaction"
|
|
4
5
|
import { CordoMagic } from "../magic"
|
|
@@ -9,8 +10,10 @@ const DefaultFileName = 'index'
|
|
|
9
10
|
export namespace RoutingResolve {
|
|
10
11
|
|
|
11
12
|
function resolvePathDots(inputPath: string, startingPath: string) {
|
|
12
|
-
if (!inputPath.startsWith('.'))
|
|
13
|
-
|
|
13
|
+
if (!inputPath.startsWith('.'))
|
|
14
|
+
return inputPath
|
|
15
|
+
if (inputPath.startsWith('./'))
|
|
16
|
+
return startingPath + inputPath.slice(1)
|
|
14
17
|
|
|
15
18
|
const cwd = startingPath.split('/')
|
|
16
19
|
if (cwd.at(-1) === DefaultFileName) cwd.pop()
|
|
@@ -75,7 +78,7 @@ export namespace RoutingResolve {
|
|
|
75
78
|
const start = resolvePathDots(path, startingPoint)
|
|
76
79
|
if (start === null) {
|
|
77
80
|
console.log('Invalid route', path)
|
|
78
|
-
return { routeId:
|
|
81
|
+
return { routeId: FunctCompiler.InvalidRoutePlaceholderId, args: [] }
|
|
79
82
|
}
|
|
80
83
|
|
|
81
84
|
const segments = start.split('/').filter(Boolean)
|
|
@@ -118,7 +121,7 @@ export namespace RoutingResolve {
|
|
|
118
121
|
|
|
119
122
|
if (options.length === 0) {
|
|
120
123
|
console.log('Could not find route', path, '(', path, ')')
|
|
121
|
-
return { routeId:
|
|
124
|
+
return { routeId: FunctCompiler.InvalidRoutePlaceholderId, args: [] }
|
|
122
125
|
}
|
|
123
126
|
|
|
124
127
|
const maxSpecificity = Math.max(...options.map(o => o.specificity))
|
|
@@ -127,7 +130,7 @@ export namespace RoutingResolve {
|
|
|
127
130
|
return {
|
|
128
131
|
routeId: winner.route.name!,
|
|
129
132
|
args: resolveRuntimeVars
|
|
130
|
-
? substituteRuntimeVariables(winner.args, invoker)
|
|
133
|
+
? substituteRuntimeVariables(winner.args, invoker!)
|
|
131
134
|
: winner.args,
|
|
132
135
|
routeFilePath: winner.route.filePath
|
|
133
136
|
}
|
|
@@ -19,6 +19,8 @@ export namespace FunctCompiler {
|
|
|
19
19
|
const LutArgumentIndicator = '\\'
|
|
20
20
|
/** the following argument has the same value as an earlier argument */
|
|
21
21
|
const ReferenceArgumentIndicator = '|'
|
|
22
|
+
/** placeholder route id for when the route could not be resolved */
|
|
23
|
+
export const InvalidRoutePlaceholderId = '#'.repeat(LockfileInternals.Const.idLength)
|
|
22
24
|
|
|
23
25
|
//
|
|
24
26
|
|
|
@@ -39,9 +41,13 @@ export namespace FunctCompiler {
|
|
|
39
41
|
const extraValues: string[] = []
|
|
40
42
|
|
|
41
43
|
// encode cwd
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
if (CordoMagic.getCwd()) {
|
|
45
|
+
const { routeId, args } = RoutingResolve.getRouteFromPath(CordoMagic.getCwd(), false)
|
|
46
|
+
command.push(routeId)
|
|
47
|
+
argus.push(...args)
|
|
48
|
+
} else {
|
|
49
|
+
command.push(InvalidRoutePlaceholderId)
|
|
50
|
+
}
|
|
45
51
|
|
|
46
52
|
// encode functs
|
|
47
53
|
for (const fun of list) {
|
|
@@ -181,8 +187,6 @@ export namespace FunctCompiler {
|
|
|
181
187
|
}
|
|
182
188
|
|
|
183
189
|
const cwdRoute = readNextRoute()
|
|
184
|
-
if (!cwdRoute)
|
|
185
|
-
return out
|
|
186
190
|
|
|
187
191
|
out.cwd = cwdRoute
|
|
188
192
|
|