@sailshq/language-server 0.0.4 → 0.0.5

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.
@@ -4,6 +4,17 @@ const fs = require('fs').promises
4
4
  const findProjectRoot = require('../helpers/find-project-root')
5
5
  const findFnLine = require('../helpers/find-fn-line')
6
6
 
7
+ function camelToKebabCase(str) {
8
+ return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)
9
+ }
10
+
11
+ function normalizeHelperPath(helperPath) {
12
+ const parts = helperPath.split('/')
13
+ const fileName = parts.pop() // Get the last part (file name)
14
+ const normalizedFileName = camelToKebabCase(fileName)
15
+ return [...parts, normalizedFileName].join('/')
16
+ }
17
+
7
18
  module.exports = async function goToHelper(document, position) {
8
19
  const helperInfo = extractHelperInfo(document, position)
9
20
 
@@ -12,9 +23,11 @@ module.exports = async function goToHelper(document, position) {
12
23
  }
13
24
 
14
25
  const projectRoot = await findProjectRoot(document.uri)
26
+ const normalizedHelperPath = normalizeHelperPath(
27
+ helperInfo.helperPath.join('/')
28
+ )
15
29
  const fullHelperPath =
16
- path.join(projectRoot, 'api', 'helpers', ...helperInfo.helperPath) + '.js'
17
-
30
+ path.join(projectRoot, 'api', 'helpers', normalizedHelperPath) + '.js'
18
31
  if (fullHelperPath) {
19
32
  const fnLineNumber = await findFnLine(fullHelperPath)
20
33
  return lsp.Location.create(
@@ -12,7 +12,8 @@ module.exports = async function loadSails(workspaceUri, operation) {
12
12
  new Sails().load(
13
13
  {
14
14
  hooks: { shipwright: false },
15
- log: { level: 'silent' }
15
+ log: { level: 'silent' },
16
+ models: { migrate: 'safe' }
16
17
  },
17
18
  (err, sails) => {
18
19
  if (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sailshq/language-server",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "Language Server Protocol server for Sails Language Service",
5
5
  "homepage": "https://sailjs.com",
6
6
  "repository": {