massimo-cli 0.1.3 → 0.2.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/README.md CHANGED
@@ -1,11 +1,11 @@
1
- # @platformatic/massimo-cli
1
+ # massimo-cli
2
2
 
3
3
  Check out the full documentation for Massimo on [massimohttp.dev](https://massimohttp.dev).
4
4
 
5
5
  ## Install
6
6
 
7
7
  ```sh
8
- npm install @platformatic/massimo-cli
8
+ npm install massimo-cli
9
9
  ```
10
10
 
11
11
  ## License
package/index.js CHANGED
@@ -82,9 +82,9 @@ async function writeOpenAPIClient (
82
82
  withCredentials,
83
83
  propsOptional
84
84
  })
85
- await writeFile(join(folder, `${name}-types.d.ts`), types)
85
+ await writeFile(join(folder, `${name}-types.d.mts`), types)
86
86
  if (generateImplementation) {
87
- const extension = language === 'js' ? 'js' : 'ts'
87
+ const extension = language === 'js' ? 'mjs' : 'mts'
88
88
  await writeFile(join(folder, `${name}.${extension}`), implementation)
89
89
  }
90
90
  } else {
@@ -98,9 +98,9 @@ async function writeOpenAPIClient (
98
98
  typesComment,
99
99
  propsOptional
100
100
  })
101
- await writeFile(join(folder, `${name}.d.ts`), types)
101
+ await writeFile(join(folder, `${name}.d.mts`), types)
102
102
  if (generateImplementation) {
103
- await writeFile(join(folder, `${name}.js`), implementation)
103
+ await writeFile(join(folder, `${name}.mjs`), implementation)
104
104
  }
105
105
 
106
106
  if (!typesOnly) {
@@ -115,9 +115,9 @@ async function writeGraphQLClient (folder, name, schema, url, generateImplementa
115
115
  const clientSchema = graphql.buildClientSchema(schema)
116
116
  const sdl = graphql.printSchema(clientSchema)
117
117
  await writeFile(join(folder, `${name}.schema.graphql`), sdl)
118
- await writeFile(join(folder, `${name}.d.ts`), types)
118
+ await writeFile(join(folder, `${name}.d.mts`), types)
119
119
  if (generateImplementation) {
120
- await writeFile(join(folder, `${name}.js`), implementation)
120
+ await writeFile(join(folder, `${name}.mjs`), implementation)
121
121
  }
122
122
  await writeFile(join(folder, 'package.json'), getPackageJSON({ name, generateImplementation }))
123
123
  }
@@ -427,11 +427,11 @@ async function downloadAndProcess (options) {
427
427
  function getPackageJSON ({ name, generateImplementation }) {
428
428
  const obj = {
429
429
  name,
430
- types: `./${name}.d.ts`
430
+ types: `./${name}.d.mts`
431
431
  }
432
432
 
433
433
  if (generateImplementation) {
434
- obj.main = `./${name}.js`
434
+ obj.main = `./${name}.mjs`
435
435
  }
436
436
 
437
437
  return JSON.stringify(obj, null, 2)
@@ -1,6 +1,6 @@
1
- import { generateOperationId } from '@platformatic/massimo'
2
1
  import camelcase from 'camelcase'
3
2
  import CodeBlockWriter from 'code-block-writer'
3
+ import { generateOperationId } from 'massimo'
4
4
  import { writeOperations } from './openapi-common.js'
5
5
  import {
6
6
  capitalize,
@@ -111,13 +111,13 @@ function generateFrontendImplementationFromOpenAPI ({
111
111
  writer.write('function sanitizeUrl(url)').block(() => {
112
112
  writer.writeLine("if (url.endsWith('/')) { return url.slice(0, -1) } else { return url }")
113
113
  })
114
- writer.writeLine(`/** @type {import('./${name}-types.d.ts').${camelCaseName}['setBaseUrl']} */`)
114
+ writer.writeLine(`/** @type {import('./${name}-types.d.mts').${camelCaseName}['setBaseUrl']} */`)
115
115
  writer.writeLine('export const setBaseUrl = (newUrl) => { baseUrl = sanitizeUrl(newUrl) }')
116
116
  writer.newLine()
117
- writer.writeLine(`/** @type {import('./${name}-types.d.ts').${camelCaseName}['setDefaultHeaders']} */`)
117
+ writer.writeLine(`/** @type {import('./${name}-types.d.mts').${camelCaseName}['setDefaultHeaders']} */`)
118
118
  writer.writeLine('export const setDefaultHeaders = (headers) => { defaultHeaders = headers }')
119
119
  writer.newLine()
120
- writer.writeLine(`/** @type {import('./${name}-types.d.ts').${camelCaseName}['setDefaultFetchParams']} */`)
120
+ writer.writeLine(`/** @type {import('./${name}-types.d.mts').${camelCaseName}['setDefaultFetchParams']} */`)
121
121
  writer.writeLine('export const setDefaultFetchParams = (fetchParams) => { defaultFetchParams = fetchParams }')
122
122
  writer.newLine()
123
123
  writer.write('function headersToJSON(headers) ').block(() => {
@@ -196,7 +196,9 @@ function generateFrontendImplementationFromOpenAPI ({
196
196
  const quotedParams = queryParams.map(qp => `'${qp}'`)
197
197
  let queryParametersType = ''
198
198
  if (isTsLang) {
199
- queryParametersType = `: (keyof NonNullable<Types.${fullRequest ? `${operationRequestName}['query']` : operationRequestName}>)[]`
199
+ queryParametersType = `: (keyof NonNullable<Types.${
200
+ fullRequest ? `${operationRequestName}['query']` : operationRequestName
201
+ }>)[]`
200
202
  }
201
203
  writer.writeLine(`const queryParameters${queryParametersType} = [${quotedParams.join(', ')}]`)
202
204
  writer.writeLine('const searchParams = new URLSearchParams()')
@@ -352,7 +354,7 @@ function generateFrontendImplementationFromOpenAPI ({
352
354
  // ```
353
355
  //
354
356
  writer
355
- .writeLine(`/** @type {import('./${name}-types.d.ts').${camelCaseName}['${operationId}']} */`)
357
+ .writeLine(`/** @type {import('./${name}-types.d.mts').${camelCaseName}['${operationId}']} */`)
356
358
  .write(`export const ${operationId} = async (request) =>`)
357
359
  .block(() => {
358
360
  writer.write(`return await ${underscoredOperationId}(baseUrl, request)`)
@@ -23,7 +23,7 @@ function generateTypesFromGraphQL ({ schema, name }) {
23
23
 
24
24
  const functionName = `generate${capitalize(camelcasedName)}Client`
25
25
 
26
- writer.writeLine("import { type PlatformaticClientOptions } from '@platformatic/massimo'")
26
+ writer.writeLine("import { type PlatformaticClientOptions } from 'massimo'")
27
27
  writer.blankLine()
28
28
 
29
29
  writer.write('interface GraphQLQueryOptions').block(() => {
@@ -69,7 +69,7 @@ function generateImplementationFromGraqhQL ({ name, url }) {
69
69
  useSingleQuote: true
70
70
  })
71
71
 
72
- writer.writeLine("import { buildGraphQLClient } from '@platformatic/massimo'")
72
+ writer.writeLine("import { buildGraphQLClient } from 'massimo'")
73
73
  writer.writeLine("import { join } from 'node:path'")
74
74
  writer.blankLine()
75
75
 
@@ -1,4 +1,4 @@
1
- import { hasDuplicatedParameters } from '@platformatic/massimo'
1
+ import { hasDuplicatedParameters } from 'massimo'
2
2
  import camelcase from 'camelcase'
3
3
  import CodeBlockWriter from 'code-block-writer'
4
4
  import jsonpointer from 'jsonpointer'
@@ -1,4 +1,4 @@
1
- import { generateOperationId } from '@platformatic/massimo'
1
+ import { generateOperationId } from 'massimo'
2
2
  import CodeBlockWriter from 'code-block-writer'
3
3
  import { writeOperations } from './openapi-common.js'
4
4
  import { capitalize, toJavaScriptName } from './utils.js'
@@ -36,7 +36,7 @@ function generateImplementationFromOpenAPI ({ name, fullResponse, fullRequest, v
36
36
  useSingleQuote: true
37
37
  })
38
38
 
39
- writer.writeLine("import { buildOpenAPIClient } from '@platformatic/massimo'")
39
+ writer.writeLine("import { buildOpenAPIClient } from 'massimo'")
40
40
  writer.writeLine("import { join } from 'node:path'")
41
41
  writer.blankLine()
42
42
 
@@ -117,7 +117,7 @@ function generateTypesFromOpenAPI ({
117
117
  }
118
118
 
119
119
  writer.writeLine(
120
- "import { type GetHeadersOptions, type PlatformaticClientOptions, type StatusCode1xx, type StatusCode2xx, type StatusCode3xx, type StatusCode4xx, type StatusCode5xx } from '@platformatic/massimo'"
120
+ "import { type GetHeadersOptions, type PlatformaticClientOptions, type StatusCode1xx, type StatusCode2xx, type StatusCode3xx, type StatusCode4xx, type StatusCode5xx } from 'massimo'"
121
121
  )
122
122
  writer.writeLine("import { type FormData } from 'undici'")
123
123
  writer.blankLine()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "massimo-cli",
3
- "version": "0.1.3",
3
+ "version": "0.2.0",
4
4
  "description": "A client for HTTP services.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -30,7 +30,7 @@
30
30
  "pino-pretty": "^13.0.0",
31
31
  "undici": "^7.0.0",
32
32
  "yaml": "^2.4.1",
33
- "@platformatic/massimo": "npm:massimo@0.1.3"
33
+ "massimo": "0.2.0"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@platformatic/composer": "3.0.0-alpha.6",