@pikku/cli 0.9.10 → 0.9.12
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/CHANGELOG.md +12 -0
- package/dist/src/serialize-pikku-types.js +5 -4
- package/dist/src/utils.js +16 -5
- package/package.json +1 -1
- package/src/serialize-pikku-types.ts +5 -4
- package/src/utils.ts +16 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @pikku/cli
|
|
2
2
|
|
|
3
|
+
## 0.9.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- eb8ed09: feat: only write files if the content changed / file doesn't exist, this stops triggering restarts for development
|
|
8
|
+
|
|
9
|
+
## 0.9.11
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 0181433: fix: fixing cli pikku-types for channels (allowing sessionless as well)
|
|
14
|
+
|
|
3
15
|
## 0.9.10
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -6,7 +6,7 @@ export const serializePikkuTypes = (userSessionTypeImport, userSessionTypeName,
|
|
|
6
6
|
* This is used to provide the application types in the typescript project
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { CorePikkuFunctionConfig, CorePikkuPermission, CorePikkuMiddleware, addHTTPMiddleware, addMiddleware, addPermission
|
|
9
|
+
import { CorePikkuFunctionConfig, CorePikkuPermission, CorePikkuMiddleware, addHTTPMiddleware, addMiddleware, addPermission } from '@pikku/core'
|
|
10
10
|
import { CorePikkuFunction, CorePikkuFunctionSessionless } from '@pikku/core/function'
|
|
11
11
|
import { CoreHTTPFunctionWiring, AssertHTTPWiringParams, wireHTTP as wireHTTPCore } from '@pikku/core/http'
|
|
12
12
|
import { CoreScheduledTask, wireScheduler as wireSchedulerCore } from '@pikku/core/scheduler'
|
|
@@ -86,7 +86,7 @@ type PikkuFunctionSessionless<
|
|
|
86
86
|
Out = never,
|
|
87
87
|
ChannelData = null, // null means optional channel
|
|
88
88
|
MCPData = null, // null means optional MCP
|
|
89
|
-
RequiredServices extends Services =
|
|
89
|
+
RequiredServices extends Services = Services &
|
|
90
90
|
{ rpc: TypedPikkuRPC } & (
|
|
91
91
|
[ChannelData] extends [null]
|
|
92
92
|
? { channel?: PikkuChannel<unknown, Out> } // Optional channel
|
|
@@ -112,7 +112,7 @@ type PikkuFunction<
|
|
|
112
112
|
Out = never,
|
|
113
113
|
ChannelData = null, // null means optional channel
|
|
114
114
|
MCPData = null, // null means optional MCP
|
|
115
|
-
RequiredServices extends Services =
|
|
115
|
+
RequiredServices extends Services = Services &
|
|
116
116
|
{ rpc: TypedPikkuRPC } & (
|
|
117
117
|
[ChannelData] extends [null]
|
|
118
118
|
? { channel?: PikkuChannel<unknown, Out> } // Optional channel
|
|
@@ -140,7 +140,8 @@ type HTTPWiring<In, Out, Route extends string> = CoreHTTPFunctionWiring<In, Out,
|
|
|
140
140
|
* @template ChannelData - Type of data exchanged through the channel
|
|
141
141
|
* @template Channel - String literal type for the channel name
|
|
142
142
|
*/
|
|
143
|
-
type
|
|
143
|
+
type ChannelWiringFunction<I, O, C = {}> = PikkuFunctionSessionless<I, O, C> | PikkuFunction<I, O, C>
|
|
144
|
+
type ChannelWiring<ChannelData, Channel extends string> = CoreChannel<ChannelData, Channel, ChannelWiringFunction<void, unknown> | ChannelWiringFunction<void, unknown, ChannelData>, ChannelWiringFunction<void, void> | ChannelWiringFunction<void, void, ChannelData>, ChannelWiringFunction<any, any> | ChannelWiringFunction<any, any, ChannelData>, PikkuPermission>
|
|
144
145
|
|
|
145
146
|
/**
|
|
146
147
|
* Type definition for scheduled tasks that run at specified intervals.
|
package/dist/src/utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { relative, dirname, resolve } from 'path';
|
|
2
|
-
import { mkdir, writeFile } from 'fs/promises';
|
|
2
|
+
import { mkdir, readFile, writeFile } from 'fs/promises';
|
|
3
3
|
import chalk from 'chalk';
|
|
4
4
|
import { fileURLToPath } from 'url';
|
|
5
5
|
import { readFileSync } from 'fs';
|
|
@@ -165,10 +165,21 @@ export const writeFileInDir = async (logger, path, content, { ignoreModifyCommen
|
|
|
165
165
|
else {
|
|
166
166
|
content = `${ignoreModifyComment ? '' : DO_NOT_MODIFY_COMMENT}${content}`;
|
|
167
167
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
168
|
+
// Try to read existing file content
|
|
169
|
+
let existingContent;
|
|
170
|
+
try {
|
|
171
|
+
existingContent = await readFile(path, 'utf-8');
|
|
172
|
+
}
|
|
173
|
+
catch (error) {
|
|
174
|
+
// File doesn't exist, so we need to write it
|
|
175
|
+
}
|
|
176
|
+
// Only write if content has changed or file doesn't exist
|
|
177
|
+
if (existingContent !== content) {
|
|
178
|
+
await mkdir(dirname(path), { recursive: true });
|
|
179
|
+
await writeFile(path, content, 'utf-8');
|
|
180
|
+
if (logWrite) {
|
|
181
|
+
logger.success(`✓ File written to ${path}`);
|
|
182
|
+
}
|
|
172
183
|
}
|
|
173
184
|
};
|
|
174
185
|
export const logCommandInfoAndTime = async (logger, commandStart, commandEnd, [skipCondition, skipMessage = 'none found'], callback) => {
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@ export const serializePikkuTypes = (
|
|
|
14
14
|
* This is used to provide the application types in the typescript project
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import { CorePikkuFunctionConfig, CorePikkuPermission, CorePikkuMiddleware, addHTTPMiddleware, addMiddleware, addPermission
|
|
17
|
+
import { CorePikkuFunctionConfig, CorePikkuPermission, CorePikkuMiddleware, addHTTPMiddleware, addMiddleware, addPermission } from '@pikku/core'
|
|
18
18
|
import { CorePikkuFunction, CorePikkuFunctionSessionless } from '@pikku/core/function'
|
|
19
19
|
import { CoreHTTPFunctionWiring, AssertHTTPWiringParams, wireHTTP as wireHTTPCore } from '@pikku/core/http'
|
|
20
20
|
import { CoreScheduledTask, wireScheduler as wireSchedulerCore } from '@pikku/core/scheduler'
|
|
@@ -94,7 +94,7 @@ type PikkuFunctionSessionless<
|
|
|
94
94
|
Out = never,
|
|
95
95
|
ChannelData = null, // null means optional channel
|
|
96
96
|
MCPData = null, // null means optional MCP
|
|
97
|
-
RequiredServices extends Services =
|
|
97
|
+
RequiredServices extends Services = Services &
|
|
98
98
|
{ rpc: TypedPikkuRPC } & (
|
|
99
99
|
[ChannelData] extends [null]
|
|
100
100
|
? { channel?: PikkuChannel<unknown, Out> } // Optional channel
|
|
@@ -120,7 +120,7 @@ type PikkuFunction<
|
|
|
120
120
|
Out = never,
|
|
121
121
|
ChannelData = null, // null means optional channel
|
|
122
122
|
MCPData = null, // null means optional MCP
|
|
123
|
-
RequiredServices extends Services =
|
|
123
|
+
RequiredServices extends Services = Services &
|
|
124
124
|
{ rpc: TypedPikkuRPC } & (
|
|
125
125
|
[ChannelData] extends [null]
|
|
126
126
|
? { channel?: PikkuChannel<unknown, Out> } // Optional channel
|
|
@@ -148,7 +148,8 @@ type HTTPWiring<In, Out, Route extends string> = CoreHTTPFunctionWiring<In, Out,
|
|
|
148
148
|
* @template ChannelData - Type of data exchanged through the channel
|
|
149
149
|
* @template Channel - String literal type for the channel name
|
|
150
150
|
*/
|
|
151
|
-
type
|
|
151
|
+
type ChannelWiringFunction<I, O, C = {}> = PikkuFunctionSessionless<I, O, C> | PikkuFunction<I, O, C>
|
|
152
|
+
type ChannelWiring<ChannelData, Channel extends string> = CoreChannel<ChannelData, Channel, ChannelWiringFunction<void, unknown> | ChannelWiringFunction<void, unknown, ChannelData>, ChannelWiringFunction<void, void> | ChannelWiringFunction<void, void, ChannelData>, ChannelWiringFunction<any, any> | ChannelWiringFunction<any, any, ChannelData>, PikkuPermission>
|
|
152
153
|
|
|
153
154
|
/**
|
|
154
155
|
* Type definition for scheduled tasks that run at specified intervals.
|
package/src/utils.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { relative, dirname, resolve } from 'path'
|
|
2
2
|
import { PathToNameAndType, InspectorState, TypesMap } from '@pikku/inspector'
|
|
3
|
-
import { mkdir, writeFile } from 'fs/promises'
|
|
3
|
+
import { mkdir, readFile, writeFile } from 'fs/promises'
|
|
4
4
|
import chalk from 'chalk'
|
|
5
5
|
import { fileURLToPath } from 'url'
|
|
6
6
|
import { readFileSync } from 'fs'
|
|
@@ -301,11 +301,22 @@ export const writeFileInDir = async (
|
|
|
301
301
|
content = `${ignoreModifyComment ? '' : DO_NOT_MODIFY_COMMENT}${content}`
|
|
302
302
|
}
|
|
303
303
|
|
|
304
|
-
|
|
305
|
-
|
|
304
|
+
// Try to read existing file content
|
|
305
|
+
let existingContent: string | undefined
|
|
306
|
+
try {
|
|
307
|
+
existingContent = await readFile(path, 'utf-8')
|
|
308
|
+
} catch (error) {
|
|
309
|
+
// File doesn't exist, so we need to write it
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// Only write if content has changed or file doesn't exist
|
|
313
|
+
if (existingContent !== content) {
|
|
314
|
+
await mkdir(dirname(path), { recursive: true })
|
|
315
|
+
await writeFile(path, content, 'utf-8')
|
|
306
316
|
|
|
307
|
-
|
|
308
|
-
|
|
317
|
+
if (logWrite) {
|
|
318
|
+
logger.success(`✓ File written to ${path}`)
|
|
319
|
+
}
|
|
309
320
|
}
|
|
310
321
|
}
|
|
311
322
|
|