deploy-webapp 1.0.1 → 1.0.2
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/install.js +33 -1
- package/package.json +1 -1
package/install.js
CHANGED
|
@@ -4,7 +4,37 @@ const path = require('path');
|
|
|
4
4
|
// Caminho do pacote instalado
|
|
5
5
|
const packagePath = __dirname;
|
|
6
6
|
const utilsPath = path.join(packagePath, 'src', 'utils');
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
// Encontrar a raiz do projeto (subir de node_modules até encontrar package.json do projeto)
|
|
9
|
+
function findProjectRoot(startPath) {
|
|
10
|
+
// Se estamos em node_modules, subir até a raiz do projeto
|
|
11
|
+
if (startPath.includes('node_modules')) {
|
|
12
|
+
// Encontrar o índice de node_modules e pegar o diretório pai
|
|
13
|
+
const nodeModulesIndex = startPath.indexOf('node_modules');
|
|
14
|
+
const candidateRoot = startPath.substring(0, nodeModulesIndex);
|
|
15
|
+
|
|
16
|
+
// Verificar se existe package.json nesse diretório (raiz do projeto)
|
|
17
|
+
const packageJsonPath = path.join(candidateRoot, 'package.json');
|
|
18
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
19
|
+
// Verificar se não é o package.json do próprio pacote deploy-webapp
|
|
20
|
+
try {
|
|
21
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
22
|
+
if (packageJson.name !== 'deploy-webapp') {
|
|
23
|
+
return candidateRoot;
|
|
24
|
+
}
|
|
25
|
+
} catch (e) {
|
|
26
|
+
// Se não conseguir ler, assumir que é a raiz
|
|
27
|
+
return candidateRoot;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Fallback: usar process.cwd() (diretório onde o comando foi executado)
|
|
33
|
+
// Isso funciona porque quando yarn/npm instala, o cwd é a raiz do projeto
|
|
34
|
+
return process.cwd();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const projectRoot = findProjectRoot(packagePath);
|
|
8
38
|
|
|
9
39
|
// Arquivos a serem copiados (com seus caminhos de origem)
|
|
10
40
|
const filesToCopy = [
|
|
@@ -14,6 +44,8 @@ const filesToCopy = [
|
|
|
14
44
|
];
|
|
15
45
|
|
|
16
46
|
console.log('📦 deploy-webapp: Configurando arquivos de configuração...');
|
|
47
|
+
console.log(` 📍 Pacote instalado em: ${packagePath}`);
|
|
48
|
+
console.log(` 📍 Raiz do projeto: ${projectRoot}`);
|
|
17
49
|
|
|
18
50
|
// Verificar se estamos em node_modules (instalação do pacote)
|
|
19
51
|
const isInstalled = packagePath.includes('node_modules');
|