@@ -5,8 +5,9 @@ import { Account, RunTypeOptions } from "@tago-io/sdk";
55
66import { getEnvironmentConfig , IConfigFile , IEnvironment } from "../../lib/config-file.js" ;
77import { detectRuntime } from "../../lib/current-runtime.js" ;
8- import { getCurrentFolder } from "../../lib/get-current-folder.js" ;
98import { errorHandler , infoMSG , successMSG } from "../../lib/messages.js" ;
9+ import { requireLocalScope } from "../../lib/resolve-scope.js" ;
10+ import { printScopeBanner } from "../../lib/scope-notice.js" ;
1011import { searchName } from "../../lib/search-name.js" ;
1112import { chooseAnalysisListFromConfig } from "../../prompt/choose-analysis-list-config.js" ;
1213import { confirmAnalysisFromConfig } from "../../prompt/confirm-analysis-list.js" ;
@@ -20,18 +21,19 @@ interface BuildScriptParams {
2021 config : EnvConfig ;
2122 runtime : string ;
2223 path : string ;
24+ /** Resolved local-scope project root. */
25+ projectRoot : string ;
2326}
2427
2528/**
2629 * Returns an object containing the paths for analysis, build and current folder.
2730 * @param config - An object containing the configuration for the environment.
2831 * @returns An object containing the paths for analysis, build and current folder.
2932 */
30- function getPaths ( config : EnvConfig ) {
31- const folderPath = getCurrentFolder ( ) ;
33+ function getPaths ( config : EnvConfig , projectRoot : string ) {
3234 const buildPath = config . buildPath || `./build` ;
3335 const analysisPath = config . analysisPath || `./src/analysis` ;
34- return { analysisPath, buildPath, folderPath } ;
36+ return { analysisPath, buildPath, folderPath : projectRoot } ;
3537}
3638
3739/**
@@ -64,8 +66,8 @@ async function deleteOldFile(buildedFile: string) {
6466 * @param params - The parameters for building and uploading the script.
6567 */
6668async function buildScript ( params : BuildScriptParams ) {
67- const { account, scriptName, analysisID, config, runtime, path } = params ;
68- const { analysisPath, buildPath, folderPath } = getPaths ( config ) ;
69+ const { account, scriptName, analysisID, config, runtime, path, projectRoot } = params ;
70+ const { analysisPath, buildPath, folderPath } = getPaths ( config , projectRoot ) ;
6971
7072 let analysisFile ;
7173 if ( path ) {
@@ -142,6 +144,10 @@ async function deployAnalysis(cmdScriptName: string, options: IDeployOptions) {
142144 errorHandler ( 'Did you mean "tagoio deploy --all"? The "all" positional argument is no longer supported.' ) ;
143145 }
144146
147+ // Analysis development requires a project directory.
148+ const scope = requireLocalScope ( "analysis-deploy" ) ;
149+ printScopeBanner ( scope , options . silent ) ;
150+
145151 const config = getEnvironmentConfig ( options . environment ) ;
146152 if ( ! config ) {
147153 errorHandler ( "Environment not found" ) ;
@@ -155,12 +161,12 @@ async function deployAnalysis(cmdScriptName: string, options: IDeployOptions) {
155161 }
156162
157163 // --all skips selection entirely; everything in analysisList with a fileName ships.
158- let scriptList = config . analysisList . filter ( ( x ) => x . fileName ) ;
164+ let scriptList = ( config . analysisList ?? [ ] ) . filter ( ( x ) => x . fileName ) ;
159165 if ( ! options . all ) {
160166 if ( ! cmdScriptName ) {
161167 scriptList = await chooseAnalysisListFromConfig ( scriptList ) ;
162168 } else {
163- const analysisFound : IEnvironment [ "analysisList" ] [ 0 ] = searchName (
169+ const analysisFound : NonNullable < IEnvironment [ "analysisList" ] > [ number ] = searchName (
164170 cmdScriptName ,
165171 scriptList . map ( ( x ) => ( { names : [ x . name , x . fileName ] , value : x } ) ) ,
166172 ) ;
@@ -202,6 +208,7 @@ async function deployAnalysis(cmdScriptName: string, options: IDeployOptions) {
202208 config,
203209 runtime,
204210 path : path || "" ,
211+ projectRoot : scope . root ,
205212 } ) ;
206213 }
207214 process . exit ( ) ;
0 commit comments